Control Structures - Study Mode

[#56] What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input) #include <stdio.h>
void main()
{
char *ch

printf("enter a value between 1 to 3:")

scanf("%s", ch)

switch (ch)
{
case "1":
printf("1")

break

case "2":
printf("2")

break

}
}
Correct Answer

(C) Compile time error

[#57] What will be the output of the following C code? #include <stdio.h>
void main()
{
int i = 0

while (i < 10)
{
i++

printf("hi
")

while (i < 8)
{
i++

printf("hello
")

}
}
}
Correct Answer

(D) Hi is printed once, hello 7 times and then hi 2 times

[#58] What will be the output of the following C code? #include <stdio.h>
void main()
{
int i = 0

while (++i)
{
printf("H")

}
}
Correct Answer

(B) H is printed infinite times

[#59] What will be the output of the following C code? #include <stdio.h>
void main()
{
double k = 0

for (k = 0.0

k < 3.0

k++)

printf("%lf", k)

}
Correct Answer

(C) 3.000000

[#60] What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input) #include <stdio.h>
void main()
{
int ch

printf("enter a value between 1 to 2:")

scanf("%d", &ch)

switch (ch)
{
case 1:
printf("1
")

default:
printf("2
")

}
}
Correct Answer

(C) 1 2