Write a Program to find Sum of n numbers??
#include<iostream.h>
#include<conio.h>
int main()
{
int n_limit, result_sum, loop_v;
cout<<"Enter N Limit: ";
cin>>n_limit;
result_sum=0;
for(loop_v=0;loop_v<n_limit;loop_v++);
{
result_sum=result_sum+loop_v;
}
cout<<result_sum;
return 00;
}
Output:
Enter N Limit: 5
15
#include<iostream.h>
#include<conio.h>
int main()
{
int n_limit, result_sum, loop_v;
cout<<"Enter N Limit: ";
cin>>n_limit;
result_sum=0;
for(loop_v=0;loop_v<n_limit;loop_v++);
{
result_sum=result_sum+loop_v;
}
cout<<result_sum;
return 00;
}
Output:
Enter N Limit: 5
15
No comments:
Post a Comment