Wednesday, 25 May 2016

PROGRAM ON FOR LOOP

#include<iostream.h>

#include<conio.h>

void main()

        {


clrscr();   \\this will clear the previous output generated

int a; \\this is called as variable declaration

int sum = 0; \\this is variable  initialization

for(a=0 ; a<=10; a++) \\the general syntax of for loop is for(variable intialization; condition;                                                    increment/decrement operator)

{

sum=sum+a;

}

cout<<sum; \\this will print the value of variable sum

getch();

}

No comments:

Post a Comment