Computer Science, asked by leelavatidevadiga456, 11 months ago

How many 'a' will be printed when the following code is executed?
#include
int main()
{
int i=0;
char c='a';
while(i<5)
{
i++;
switch (c)
{
case 'a':
printf ("%c",c);
break;
}
}
printf ("a\n");
return 0;
}

HINT:-numeric answer

Answers

Answered by poojan
2

Answer:

6

Explanation:

As i is initialized with 0,

with while condition of i<5, followed by incrementation,

the i enters the loop for 5 times with values 0,1,2,3,4 resulting 5 'a's to get printed.

And, after the termination of loop, print("a\n") statement prints another a (now the count is 6) and goes to new line; thereby the program ends.

So, the total number of 'a's getting printed is 6 in number.

Answered by Anonymous
0

hope it work.........

Attachments:
Similar questions