The given code is supposed to find the sum of numbers from 1 to n. Due to some logical errors or syntax errors, it fails to print the desired result. Fix the code to pass the test case.
Sample Input:
5
Sample Output:
15
1
#include
2
int main(){
3
int n=5, sum;
4
std::cin>>n;
5
for(int i = 1; i
6
sum = sum + i
7
}
8
std::cout<
9
}
Answers
Answered by
0
Answer:
coding of QBasic to find sum of no.
Answered by
4
Error :
In 5 : i<=6
In 8 : cout<<sum;
Similar questions