In: Computer Science
Directions: Convert the following problems below to c++ equivalent
Problem 2:
Program code to copy
#include <iostream>
using namespace std;
int main(){
int num, num_copy;
//Taking integer input
cout<<"Enter a number: ";
cin>>num;
//Applying constraint according to question
//Storing number
num_copy = num;
//Multiplying number by 3
num = num*3;
//Adding 45 to number
num = num + 45;
//Multiplying the number by 2
num = num * 2;
//Dividing the number by 2
num = num / 6;
//Subtracting the original number from
answer
num = num - num_copy;
cout<<"Value after operations: "<<num;
return 0;
}
Program Screenshot with different inputs and outputs
Code is working for negative number also
Checking for large inputs