Answer to Question #16689 in C++ for Junaid

Question #16689
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
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS