No. of times '*' will be printed by the following C code is _____
#include<stdio.h> void foo(int x) { switch(x){ case 1: printf("*"); case 2: printf("*"); case 3: printf("*"); default: printf("*"); } } int main() { foo(2.5); }
foo(2.5); foo(2) // converting 2.5 into int now case 2 is true so it will print *. case 3 will also print * because no break statement. default case will also print *. TOtal 3 time * will be printed.
64.3k questions
77.9k answers
244k comments
80.0k users