Write a complete program that declares an integer variable, readsa value from the keyboard into that variable, and writes tostandard output the variable's value, twice the value, and thesquare of the value, separated by spaces.

Respuesta :

Answer:

// here is code in c++.

// include headers

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variable

   int n;

   cout<<"Enter a number:";

   // read the number

   cin>>n;

   // Calculate twice of number

   int twice=2*n;

   // Calculate square of number

   int sqr=n*n;

   // print number, twice and square separated by space

   cout<<n<<" "<<twice<<" "<<sqr<<endl;

return 0;

}

Explanation:

Read an integer from user and assign it to variable "n".Calculate its twice

by multiply "n" with 2 and assign it to "twice".Then Calculate its square by

multiply n*n.Print the number, its twice and its square separated by a space.

Output:

Enter a number:5

5 10 25

ACCESS MORE