Start
print "the sum of all even numbers is infinite"
end
There are infinitely many even numbers and so the sum of all even numbers is infinity. The answer, therefore, is to write an algorithm whose only step is to output "Infinity" and then stop.
102
for (int i = 2; i < 10; i ++) printf("%d\n", i); You did say even and odd numbers between 1 and 10. That's allnumbers between 1 and 10.
sum = 0 for(n = 0; n <= 10; n += 2) sum += n;
write an algo to find the sum of even number from 1to n
They are: 292 294 296 298 and including 300 it will be five times
jgfujtf
AnswerIf A=10, B=2... Then the algoritm is :-STEP1 : START.STEP2 : A=10.STEP3 : B=02.STEP4 : C=A-B.STEP5 : PRINT C.STEP6 : STOP.AnswerYou cannot print every even number in descending order, because there is no greatest even number. Or you want something like this: infinityinfinity-2infinity-4Answerstep 1: start step 2: Input Nstep 3: If N
You can use int i; for (i = 10; i <= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.
102
#include(stdio.h) int main ()
Sum = 0 For N = 1 to 10 Sum = Sum + 2*N Next N Print Sum
Reference:http:cprogramming-bd.com/c_page2.aspx# strange number
for (int i = 2; i < 10; i ++) printf("%d\n", i); You did say even and odd numbers between 1 and 10. That's allnumbers between 1 and 10.
It is 110.
Something like this: sum = 0 for i = 2 to 20 step 2 { sum = sum + i }
Code Below: <?php $j = 100; // Set limit upper limit echo "Even Numbers are: <br/>"; for($i=1;$i<=$j;$i++) { if($i%2) { continue; } else { echo $i."<br/>"; } } ?>
#include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("\n enter the number:"); scanf("%d",&n); if(n%2==0) printf("\n the number is even"); getch(); }