I need to find S and please explain how did you find S in N is 4
#include <iostream>
int main ()
{
int n,i,s;
cout<<"Put the number of n"<<endl;
cin>>n;
s=0
for (i=1;i<=n;i++)
s=s+i
cout<<"S is<<s<<endl;
return 0
}
Printable View
I need to find S and please explain how did you find S in N is 4
#include <iostream>
int main ()
{
int n,i,s;
cout<<"Put the number of n"<<endl;
cin>>n;
s=0
for (i=1;i<=n;i++)
s=s+i
cout<<"S is<<s<<endl;
return 0
}
What?
I need to find S if N is 4...
So what's your question? Run the program and input 4.
#include <iostream.h>
#include <stdlib.h>
int main()
{
int n,i,s;
cout<<"Insert number of n"<<endl;
cin>>n;
s=o;
for(i=1;<=n;i++)
s=s+i;
cout<<"S is"<<s<<endl;
system("PAUSE");
return 0;
I have 3 erors can anyone fix them?
But before you can run it, you will need to fix the compile errors - particularly relating to missing ;
I fixed all missing ; but still 3 errors left....
Anyone has idea where am i wrong?
#include <iostream.h>
#include <stdlib.h>
int main()
{
int n,i,s;
cout<<"Insert number of n"<<endl;
cin>>n;
s=o;
for(i=1;<=n;i++)
s=s+i;
cout<<"S is"<<s<<endl;
system("PAUSE");
return 0;
This is not standard ANSI c++. For standard ANSI c++ your headers should beCode:#include <iostream.h>
Code:#include <iostream>
#include <cstdlib>
using namespace std;