Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
c++ The following program invokes p() two times. What is the printout from the last call of p(ch)? #include using namespace std; void p(char ch)
c++
The following program invokes p() two times. What is the printout from the last call of p(ch)?
#include
using namespace std;
void p(char ch)
{
static int n = 4;
while (n > 0)
{
cout << ch;
n--;
}
cout << endl;
}
int main()
{
char ch = 'a';
p(ch);
p(ch);
return 0;
}
-------------
1- aaa
2- a
3- aaaa
4- aa
5- a blank line
c++
The following program invokes p() two times. What is the printout from the last call of p(ch)?
#include
using namespace std;
void p(char ch)
{
static int n = 4;
while (n > 0)
{
cout << ch;
n--;
}
cout << endl;
}
int main()
{
char ch = 'a';
p(ch);
p(ch);
return 0;
}
-------------
1- aaa
2- a
3- aaaa
4- aa
5- a blank line
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started