Write a program that repeatedly collects positive integers from the user, stopping when the user enters a negative number or zero.
+/- Click and see the code that is about the article.
#includeint main () { int counter,first,second=0,third=0,last,finally; for (counter=1;counter<=100;counter++) { first=counter*counter; second +=first; } printf("First : %d\n",second); for (counter=1;counter<=100;counter++) { third+=counter; last=third*third; } printf("Second : %d\n",last); finally=last-second; printf("Diffirence : %d\n",finally); }
/* source : freelearncprogramming.blogspot.com */
#include <stdio.h>
int main ()
{
int counter;
for (counter=1;counter<=400000000000;counter++)
{
if (counter%1) {
continue;
}
else if (counter%2)
{
continue;
}
else if (counter%3)
{
continue;
}
else if (counter%4)
{
continue;
}
else if (counter%5)
{
continue;
}
else if (counter%6)
{
continue;
}
else if (counter%7)
{
continue;
}
else if (counter%8)
{
continue;
}
else if (counter%9)
{
continue;
}
else if (counter%10)
{
continue;
}
else if (counter%11)
{
continue;
}
else if (counter%12)
{
continue;
}
else if (counter%13)
{
continue;
}
else if (counter%14)
{
continue;
}
else if (counter%15)
{
continue;
}
else if (counter%16)
{
continue;
}
else if (counter%17)
{
continue;
}
else if (counter%18)
{
continue;
}
else if (counter%19)
{
continue;
}
else if (counter%20)
{
continue;
}
printf("%d\n",counter);
break;
}
}
| Mathematical expressions | Expressed in the C | Process |
|---|---|---|
| . X or nothing | * | multiplication |
| Mode | % | Modular quotient |
| / | / | Quotient |
| +1 | ++ | Unary increment |
| -1 | -- | Unary decrement |
| + | + | Sum |
| - | - | Difference |
| header | header |
|---|---|
| A++ (postincrement) | Firstly use A, than add 1 to the number. |
| ++A ( preincrement ) | Firstly add 1 to the A, after use number. |
| A -- ( postdecrement ) | Firstly use A, than subtract 1 to the number. |
| -- A ( predecrement ) | Firstly subtract 1 to the A, after use number. |
| header | header | header | header | header | header |
|---|---|---|---|---|---|
| c=a++ *b | c=a*b a=a+1 | c=4*5=20 a=4+1=5 | a=5 | b=5 | c=20 |
| c=++a–b | a=a+1 c=a - b | a=4+1=5 c=5 - 5=0 | a=5 | b=5 | c=0 |
| c= -- a + b -- | a=a+1 c=a+b b=b - 1 | a=4
-
1=3 c=3+5=8 b=5 - 1=4 | a=3 | b=4 | c=8 |
/* source : freelearncprogramming.blogspot.com */
#include <stdio.h>
main ()
{
int a,b,c;
float c1;
a=4;
b=5;
c=a++*b ;
c1=++a-b ;
printf ("c = %d \n",c);
printf ("c1 = %d \n",c1);
return 0;
}
/* The first C program */
/* We will see "Hello World !" on the screen. */
/* source : freelearncprogramming.blogspot.com */
#include <stdio.h>
main ()
{
printf("Hello World !");
return 0;
}
Printf ("Sample Output");However, in order to run the printf function, we need to have