World Languages, asked by physicist52071, 9 months ago

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

Answers

Answered by neelamdubey14aug
0

Explanation:

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

} please make me Brianliest

Answered by vedantsurolia12
0

Answer:

#include<iostream>

int main()

{

int n=5, sum;

std::cin>>n;

for(int i =1; i <6; i++){

 sum = sum + i;

}

std::cout<<sum;

}

Explanation

Similar questions