207k views
1 vote
Write a small program basic c++, that defines a negative integer (between ‐1 and ‐255), converts it to a positive value and then displays it on the console window.

User Dimona
by
4.7k points

1 Answer

4 votes

Answer:

#include <iostream>

using namespace std;

int main() {

int a=-156;//negative integer between -1 and -255.

a*=-1;//multiplying a to -1 so that it can become positive.

cout<<a;//printing a.

return 0;

}

Step-by-step explanation:

The above written program is in C++ and in the program an integer a is defined with a negative value in the program it is -156.Then to convert it to positive integer we have to multiply a to -1 after that printing the value of a on the screen.

User Mrsauravsahu
by
4.8k points