Answer to Question #16689 in C++ for Junaid
Write a C++program that reads in a number N from the keyboard and then add the first N integer starting at 0 together. Print the total
1
2012-10-17T10:19:47-0400
#include<iostream>
#include<conio.h>
using namespace std;
void main(void)
{
int n, value;
int sum = 0;
cout << "Enter N value: " << endl;
cin >> n;
for (int i = 0; i < n; i++){
cout << "Enter the " << i+1 << " value" << endl;
cin >> value;
sum += value;
}
cout << "The sum of " << n << " values is : " << sum <<
endl;
getch();
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment