Computer Science, asked by anakin207, 3 months ago

Write a program to display the absolute value of a number if the number is negative. If the number is positive, display a random number between 1 and given number. If the number is zero then display the message “Number is ZERO”.

Answers

Answered by parthu2011
1

Answer:

#include <iostream>

using namespace std;

int main()

{

   signed long num1 = 0;

cout << "\n\n Check whether a number is positive, negative or zero :\n";

cout << "-----------------------------------------------------------\n";  

cout << " Input a number : ";

   cin >> num1;

   if(num1 > 0)

   {

       cout << " The entered number is positive.\n\n";

   }

   else if(num1 < 0)

   {

       cout << " The entered number is negative.\n\n";

   }

   else

   {

       std::cout << " The number is zero.\n\n";

   }

   return 0;

}

Copy

Sample Output:

Check whether a number is positive, negative or zero :                

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

Input a number : 8                                                    

The entered number is positive.

Explanation:

if you are pleased with answer in turn

please subscribe my youtube chanel(Ramakrishna Nallangari youtube channel) for my effort

search for nallangari in google and find ramakrishna nallnagari and then click it and subscribe

Similar questions