Compiler: Visual C++ Express Edition 2005
Compiled on Platform: Windows XP Pro SP2
Header file: Standard
Additional library: none/default
Additional project setting: Set project to be compiled as C
Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)
Other info: none
To do: Calculating a sum of the given numbers
To show: A simple while statement
Code:
/* Demonstrates a simple while statement */
/* Don't forget to put the .h lor! */
#include <stdio>
int main()
{
int calculate, sum = 0;
/* print the numbers 1 through 12* /
/* set the initial value... */
calculate = 1;
/* set the while condition */
while(calculate <= 10)
{
/* display... */
printf("%d -->Sum = %d\n", calculate, sum);
sum = sum + calculate;
/* increment by 1...repeats */
calculate++;
}
printf("\n");
return 0;
}
Output:Code:
You find it ur self....the code is OK but failed to post the output!!!