Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
B_141125_Repetidos
Tree
primeno
Lab 8 part 2 v.07
Critical Openmp Example
Print Micro Seconds
20171116:FUNCIONES
Official Hello World
xd
C_141204_ConcatenarCadenas
Please log in to post a comment.