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.
1.start 2.n=1,s=0 3 compute s=s+n 4 compute n=n+1 5 check n<=10 go to step3 else go to step 7 6 display s 7 stop
sum = 0 for(n = 0; n <= 10; n += 2) sum += n;
write an algo to find the sum of even number from 1to n
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(); }