Decision Making


  1. The C statement “”if (p == 3 || q == 4) {}”” can be re-written as ___________.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    None of these


  1. Which of the following is an invalid if-else statement?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    if (if (ch == 1)){}



  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int n = 1;
    if (n--)
    printf("Right...");
    if (n++)
    printf("Wrong...");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Right...


  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int n = 1;
    if (n)
    printf("Everything is okay.");
    printf("Everything is not okay.\n");
    else
    printf("I have fever\n");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

     #include <stdio.h>
    int main()
    {
    int n = 1;
    if (n)
    printf("Everything is okay.");
    printf("Everything is not okay.\n");
    else
    printf("I have fever.\n");
    }



  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    if (printf("%d", printf(")))
    printf("I am Sad...");
    else if (printf("1"))
    printf("I am Happy...");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c: In function ‘main’:
    main.c:4:33: warning: missing terminating " character
    if (printf("%d", printf(")))
    ^
    main.c:4:33: error: missing terminating " character
    if (printf("%d", printf(")))
    ^~~~
    main.c:5:35: error: expected ‘)’ before ‘;’ token
    printf("We are Happy");
    ^
    main.c:5:13: warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast [-Wint-conversion]
    printf("We are Happy");
    ^~~~~~
    In file included from main.c:1:0:
    /usr/include/stdio.h:365:12: note: expected ‘const char * restrict’ but argument is of type ‘int’
    extern int printf (const char *__restrict __format, ...);
    ^~~~~~
    main.c:8:5: error: expected ‘)’ before ‘}’ token
    }
    ^
    main.c:8:5: error: expected ‘)’ before ‘}’ token
    main.c:8:5: error: expected expression before ‘}’ token