|
-
March 10th, 2012, 12:13 AM
#1
Help with building a code....
i have this problem:
Write a fragment of code that reads in a header value from the standard input and then reads in that many integers (also from standard input) and prints their sum to standard output (for loops, header values, accumulators, basic arithmetic). Declare any variables you use.
and this is my code:
int num, num2, num3;
cin >> num;
num2 = 0;
for(int i = 0; i < num; i++)
{
cin >> num3;
num2 += num3;
cout << num2;
}
but it keeps saying "Unexpected identifiers: num2, num3".
what should i change.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|