The C and C++ code snippets monologue forum

The C, C++, Code, Coder, Coding Snippets Zone for Tenouk.com

 

 
It is currently Thu Sep 09, 2010 8:04 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Calculating a sum of the given numbers
PostPosted: Mon Nov 13, 2006 8:54 am 
Offline

Joined: Wed Nov 08, 2006 11:47 pm
Posts: 91
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!!!

_________________
_::kurt cobain::_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Skin by Lucas Kane