-
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()
{
double var;
printf("Enter a value between 1 to 2:");
scanf("%lf", &var);
switch (var)
{
case 1:
printf("1");
break;
case 2:
printf("2");
break;
}
}
-
- 1
- Compilation Error
- 2
- Runtime Error
- None of these
Correct Option: B
Compilation Error
error: '::main' must return 'int'
void main()
In function 'int main()':
error: switch quantity not an integer
switch (var)