What will be the output of the
following C code?
int main()
ܕܪܟ
int color=2;
switch (color)
{
case 0: printf ("Black");
case 1: printf ("Blue");
case 2: printf ("Green");
case 3: printf("Aqua");
default: printf ("Other");
1
return 0;
3
AquaOther
Green AquaOther
O GreenAquaOtherBlackBlue
Green Aqua
Answers
Answer:
GreenAquaOther
Explanation:
I want to tell you that the output of this C program is GreenAquaOther.
The next thing is that your C program is not correct because you are not using the rules of switch statement in C programming language very well.
According to the rules of the switch statement in C programming language. Firstly we have to use the following rules of the C programming language are as follows as:
→ Code is here :
- #include<stdio.h>
- int main()
- {
- printf("Hello World");
- }
Then we have to use switch statement by writing switch(num) then we are using curely braces { then we are using case statement by using the function called printf function which comes under the library of #include<stdio.h> which is also known as the standard input output in C programming language. Then we are using break statement in the switch statement programming.
→ Code is here:
- #include<stdio.h>
- int main()
- {
- int num = 1;
- switch (num)
- {
- case 1:
- printf ("It's one");
- break;
- case 2:
- printf ("It's two");
- break;
- default:
- printf ("It's nothing");
- break;
- }
- }
Note: Output of my code is in attachment.
Learn more from this link here:
https://brainly.in/question/13634389