204k views
0 votes
A Function checkMe takes three parameters, a character and two integers. If the sum of the two integers is negative, and the character has the value 'n', the function sets the integers to zero so that when the function returns, those integers have a zero value in the caller (main) program. Otherwise the function changes the character to a 'p' (so that it is changes in the caller), no matter what it started with! Give a SAMPLE CALL from main, a prototype and a function definition for this function.

1 Answer

4 votes

Answer:

Check the explanation

Step-by-step explanation:

Here is the program with function definition and two sample calls.

Code:

#include <iostream>

using namespace std;

//checkMe FUNCTION which takes values a, b and c

void checkMe(char &a, int &b, int &c)

{

//if sum of b and c is negative and a is 'n', b and c are set to 0, otherwise a is set to 'p'

if((b+c)<0 && a=='n')

{

b = 0;

c = 0;

}

else

{

a = 'p';

}

}

int main()

{

//first test case when else part is executed

char a = 'n';

int b = 5;

int c = 6;

checkMe(a, b, c);

cout<<a<<" "<<b<<" "<<c<<endl;

//second test case when if part is executed

a = 'n';

b = -4;

c = -5;

checkMe(a, b, c);

cout<<a<<" "<<b<<" "<<c<<endl;

return 0;

}

Kindly check the Output below:

A Function checkMe takes three parameters, a character and two integers. If the sum-example-1
User Brian Dant
by
4.9k points