Hi guys, having a little problem with my first c++ course and I'm hoping someone can help me out abit here.
Write a program that asks the user for a positive integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, …50.
This is the work I have so far.
#include <iostream>
using namespace std;
int main()
int getSum;
num;
{
if( num==1)
return 1;
else
return num+(getSum(num-1));
}
main
{
cout << "enter a number";
int value;
value=Console.ReadLine();
while(value<=0)
{
cout << "value has to be positive (>0). Enter
new value.";
value=ConsoleReadLine();
}
finalValue=getSum(value);
cout << "sum is: " + finalValue";
return 0;
}
I'm getting 2 error's and also I'm not sure if I've written this program correctly... very confused and my instructor at college being a first time instructor who unfortunately can't teach doesn't help things either
:mad: