Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Loop practice
//int sum; //for i=0 to 1000 do //if (i%2=0) then //sum=sum+ij // end if // end for // print sum // end program // Program: // ask user for inputs // scan inputs // int sum // int x // scan inputs are allocated to x // for i=0 to undefined do // if (i<0) and (i>=-999) then // sum= sum+ij // print sum // end program /* program: int sum int n scanf n while n does not equal -999 if n<0 then sum+=n end if scanf n end while print sum end program */ /* run program int (max, x) scan input x while x=-1 if (x<-1) and (x>max) then max+=x end while print max */ /*#include <stdio.h> #define maxNum 5 int main() { int i=0; for(;;) printf("Hellooo\n"); } */ /* #include <stdio.h> #define maxNum 10 int main() { int i; for(i = 0; i<maxNum; ++i) { printf("i = %d\n", i); } printf("--------------------------------\n"); printf("i after the for loop = %d\n", i); printf("--------------------------------\n"); // for loop without the curly brackets {} for(i = 0; i<maxNum; ++i) printf("i = %d\n", i); } */ #include <stdio.h> int main(void) { int n; int counter=0; int sum=0; for(int i=1; i<=5; ++i) { scanf("%d", &n); if(( n >= 0 ) && ( n%2!=0)) { ++counter; sum += n; } else break; } printf("The sum of all numbers is: %d\n", sum); printf("The average of all numbers is: %f\n", (float) sum/ (float)counter); }
run
|
edit
|
history
|
help
0
Revprint
shrinken shraken shrank leave as no cold call acces program unles clownbtweak blue voda
Lab6 v1.3Sin,cos,tan,cot
18BCE2182 MIDTERM PART-B ATOMIC
incrementing values in an array
A_141117_Euclides
150109_RecursividadFactorial
A_141121_factorial02
ㅇㅇㅇ
b=1,c=1