xxcrystalxx1069 xxcrystalxx1069
  • 14-09-2019
  • Computers and Technology
contestada

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

Respuesta :

StaceeLichtenstein StaceeLichtenstein
  • 17-09-2019

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

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".

Answer Link

Otras preguntas

Question 13 of 20Select the best answer for the question13. What was the name given to the organization of farmers dedicated to calling for regulation of railro
Multiply. Write your answer in simplest form. 2/11x 1/4
How do you say "the last place I went to was the school" in preterite tense irregular
Solve 3x2 + 12x = 3.
All of the following fractions are equivalent to 1/2 , except: A.2/4 B.5/10 C.4/7 D.3/6
Which central government agency was responsible to provide news on the war?
cuales son los territorios conquistado por los turcos
Fred and ethyl had 132 flowers altogether at first. After Fred sold 1/4 of his flowers and Ethyl sold 48 of her flowers, they had the same number of flowers lef
Rewrite the multiplication problem using improper fractions. 1 5/6 x 2
Is historical context created in the monks tale