207k views
4 votes
Write a procedure that takes a positive integer as a parameter. If the number given to the procedure is no more than 30, the procedure should return the absolute difference between that number and 30. If the number is greater than 30, the procedure should return the number doubled.

User Kaali
by
4.9k points

1 Answer

8 votes

Answer:

The following code is written in C++

#include<iostream.h>

int main()

{

int n;

cin>>" Enter Number>>n;

if(n < 30)

{

cout<<"Absolute Difference is 30";

}

else

{

cout<<"Absolute Difference is "<< 2*n;

}

return 0;

}

User Aleksander
by
4.6k points