I need help with this C ++ program and Raptor: 1. Prompt the user for how many t
ID: 3531959 • Letter: I
Question
I need help with this C ++ program and Raptor:
1. Prompt the user for how many times your program should loop. Store the results in the int variable (howmany)
2. Create an int variable (sum) and set it equal to 0. Note: (sum) is an accumulator. It accumulates the result of a series of additions. We want to be sure it starts with a value of zero.
3. Create an int variable (counter) and set it equal to 1.
4.While (counter is less than or equal to howmany)
sum = sum + counter
counter = counter + 1
end loop
5. Tell the user that the sum of the numbers 1 to (howmany) equals (sum). Here the output needs to include howmany and sum in the printf statement.
6. Thank the user for using your program. Be sure to add a NL at the end of your final output statement to the screen.
7. Exit your program with a return statement.
8. Please include how to input in Raptor if known
Explanation / Answer
#include<stdio.h>
int main()
{
int howmany,sum=0,counter=1;
printf("how many times your program should loop");
scanf("%d",&howmany);
while(counter<=howmany)
{
sum+=counter;
counter++;
}
printf("the sum for %d loops is %d",counter,sum);
printf("thank u for using the program");
return 0;
}