Example HTML page

Assignment 4 : Conditional Statements MCQ

1.  What is the output of the following code?

#include <stdio.h>
int main()
{
if(“”)
printf(“Sudhakar”);
else
printf(“Welcome”);
}

2. Observe the output of the following code.

#include <stdio.h>

int main()

{

if(;)    //   semicolon inside if; hint : gives an error

printf(“Sudhakar”);

else

printf(“Welcome”);

}

3. What is the output of the following code?

#include <stdio.h>
void main()
{
    int x=50;
    if(x=1)
        printf(“TRUE”);
    else
        printf(“FALSE”);
}
4.  What is the output of the following code?
#include <stdio.h>
void main()
{
    char a=1;
    if(a–==0)
        printf(“TRUE”);
    else
        printf(“FALSE”);
}
5.  What is the output of the following code?
#include <stdio.h>
int main()
{
    if(1)
        printf(“1”);
        printf(“2”);
    else
        printf(“3”);
        printf(“4”);
    return 0;
}
6. Which of the following are correct statements?
1)  if( a==5 )   printf(“Sudhakar”);
2)  if( 5==a )   printf(“Sudhakar”);
3)  if( a=5 )   printf(“Sudhakar”);
4)  if( 5=a  )   printf(“Sudhakar”);
7. What is the output of the following fragment?#include <stdio.h>
int main(void)
{
if (10.2)       /* floating point constant */
printf(“Hello Sudhakar”);

if (0.0)       /* floating point constant */
printf(“Hello Sudhakar”);

return 0;
}

8. What is the output of the following code?

#include <stdio.h>
int main()
{
char c=65;

if (c==’A’)
printf(“Vowel”);
else
printf(“Not vowel”);

return 0;

}

9. What is the output of the following code?

#include <stdio.h>
int main()
{
char c=66;

if (c==’A’)
printf(“Vowel”);
else
printf(“Not vowel”);

return 0;

}

10.  What is the output of the following code?
#include <stdio.h>
void main()
{
int x = 5;
if (true);
printf(“hello”);
}11.  What is the output of the following code?

#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x >= 0)
printf(“true\n”);
else
printf(“false\n”);
return 0;
}

12.  What is the output of the following code?

#include<stdio.h>
int main()

{

int a = 1;

if (a–)

printf(“True”);

if (a++)

printf(“False”);
return 0;
}

13. What is the output of the following code?

#include <stdio.h>
int main()
{
int x = 0;
if (x == 1)
if (x == 0)
printf(“I am IF\n”);
else
printf(“I am Inside ELSE\n”);
else
printf(“I am outside else\n”);
}

14.  What is the output of the following code?

int main()

{

int a = 1;

if (a)

printf(“I am Sudhakar “);

printf(“I am Kaivalya\n”);

else

printf(“I am akshaya\n”);

}

15. What is the output of the following code?

#include<stdio.h>
int main()

{

if (printf(“%d”, printf(“sudhakar”)))

printf(“I am Executed”);

else if (printf(“1”))

printf(“I am not executed”);

}

Example HTML page

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest