Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HELPP I DONT GET ITT 1. Write a complete program that -declares an integer varia

ID: 3628721 • Letter: H

Question

HELPP I DONT GET ITT

1.
Write a complete program that
-declares an integer variable,
-reads a value from the keyboard into that variable, and
-writes to standard output the square of the variable's value.

Besides the number, nothing else should be written to standard output.

2.
Write a complete program that
-declares an integer variable,
-reads a value from the keyboard into that variable, and
-writes to standard output the variable's value, twice the value, and the square of the value, separated by spaces.

Besides the numbers, nothing else should be written to standard output except for spaces separating the values.

Explanation / Answer

please rate - thanks

NOTE: CRAMSTER rule - 1 question per post

hope it's ok that I prompted for the number, and when outputting went to a new line

if you didn't learn system("pause"); just get rid of it

#include <iostream>
#include <cmath>
using namespace std;
int main()
{int n;
cout<<"enter a number: ";
cin>>n;
cout<<n*n<<endl;
system("pause");
return 0;
}

-----------------------

#include <iostream>
#include <cmath>
using namespace std;
int main()
{int n;
cout<<"enter a number: ";
cin>>n;
cout<<n<<" "<<2*n<<"   "<<n*n<<endl;
system("pause");
return 0;
}

--------------------------

without what I did extra

#include <iostream>
#include <cmath>
using namespace std;
int main()
{int n;
cin>>n;
cout<<n*n;
system("pause");
return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
int main()
{int n;
cin>>n;
cout<<n<<" "<<2*n<<"   "<<n*n;
system("pause");
return 0;
}