Decision Making


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int n = 0;
    if (n == 1)
    if (n >= 0)
    printf("True...\n");
    else
    printf("False...\n");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    It will print nothing.


  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()
    {
    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


  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? (Assuming that we have entered the value 1 in the standard input)
    #include <stdio.h>
    void main()
    {
    int n;
    printf("Enter a value between 1 to 2:");
    scanf("%d", &n);
    switch (n, n + 1)
    {
    case 1:
    printf("1\n");
    break;
    case 2:
    printf("2");
    break;
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    2