Answer to Question #172856 in C++ for Panjumin

Question #172856

Develop a C++ program to find the given number is positive or negative using user-defined manipulators.


1
Expert's answer
2021-03-21T04:46:09-0400

#include <iostream>

#include <iomanip>

using namespace std;

 

// manipulator defines a positive or negative value

// to show a positive sign on positive numbers.

ostream&positive_negative(ostream&out) {

    cout << showpos;

    return out;

}

 

int main(){

  int N;

  cout<<"Enter N: ";

  cin >> N;

  cout << positive_negative << N << endl<<endl;

 

  cout<<"Enter N: ";

  cin >> N;

  cout << positive_negative << N << endl;

 

  return 0;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS