136k views
2 votes
. Write the C++ code that reads an integer from the user, and then computes that integer's absolute value.

1 Answer

5 votes

Answer:

Following are the program in C++

#include <iostream>// header file

using namespace std;

int main() // main function

{

int num; // variable declarartion

cout<<" Enter the number:";

cin>>num; // user input

num=abs(num); // finding the absolute

cout<<num; // display number

return 0;

}

Output:

Enter the number:-90

90

Step-by-step explanation:

In this program we have declared a variable "num" of type int. After that we find the absolute value by using abs function and finally display the variable "num".

User Jwm
by
7.9k points

No related questions found