#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,sum;
cout<<"enter the number to find the sum upto that :";
cin>>n;
sum=n(n+1)/2;
cout<<"the sum of all natural number upto "<<n<<"is :"<<sum;
}
How to resolve Error I'm getting below:
|error: 'n' cannot be used as a function|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
using namespace std;
int main()
{
int n,sum;
cout<<"enter the number to find the sum upto that :";
cin>>n;
sum=n(n+1)/2;
cout<<"the sum of all natural number upto "<<n<<"is :"<<sum;
}
How to resolve Error I'm getting below:
|error: 'n' cannot be used as a function|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
Comment