Program to find Addition of "n" numbers useing for loop
Program :-
#include<iostream.h>
void main()
{
int total = 0;
for(int i=1;i<11;i++) \\ 11 number i used for example
{
total = total + i;
}
cout<<"sum of first 10 numbers is :-"<<total; \\10 number i used to get output of
} \\sum of 10 numbers
Output :- sum of first 10 numbers is:- 55
It is one of the great programs for example u can just change the numbers and get the output
of any number you want
Its like
1+2+3+4 =10
This is for sum of 4 numbers.
#include<iostream.h>
void main()
{
int total = 0;
for(int i=1;i<11;i++) \\ 11 number i used for example
{
total = total + i;
}
cout<<"sum of first 10 numbers is :-"<<total; \\10 number i used to get output of
} \\sum of 10 numbers
Output :- sum of first 10 numbers is:- 55
It is one of the great programs for example u can just change the numbers and get the output
of any number you want
Its like
1+2+3+4 =10
This is for sum of 4 numbers.
Comments
Post a Comment