Home / C Programming / Control Structures :: control structures

C Programming :: Control Structures

  1. What is the output of given program if user enter value 99?

    #include<stdio.h>

    void main()

    {

    int i;

    printf("Enter a number:");

    scanf("%d", &i); // 99 is given as input.

    if(i%5 == 0){

    printf("nNumber entered is divisible by 5");

    }

    }

  2. A.

     Enter a number:99

    B.

     Enter a number:99 Number is divisible by 5

    C.

     complier error

    D.

     Run time error


  3. What is the output of given program if user enter "xyz" ?

    #include

    void main()

    {

    float age, AgeInSeconds;

    printf("Enter your age:");

    scanf("%f", &age);

    AgeInSeconds = 365 * 24 * 60 * 60 * age;

    printf("You have lived for %f seconds", AgeInSeconds);

    }

  4. A.

     Enter your age: xyz You have lived for 0 seconds

    B.

     Enter your age: xyz You have lived for 0.00000 seconds

    C.

     Enter your age: xyz "after that program will stop"

    D.

     Run time error


  5. What is the output of given program if user enter "xyz" ?

    #include

    void main()

    {

    float age, AgeInSeconds;

    int value;

    printf("Enter your age:");

    value=scanf("%f", &age);

    if(value==0){

    printf("\\nYour age is not valid");

    }

    AgeInSeconds = 365 * 24 * 60 * 60 * age;

    printf("\\n You have lived for %f seconds", AgeInSeconds);

    }

  6. A.

     Enter your age : xyz Your age is not valid

    B.

     Enter your age: xyz You have lived for 0 seconds

    C.

     Enter your age: xyz Your age is not valid

    D.

     Complier error


  7. What will be the output of the given program?

    #include<stdio.h>

    void main()

    {

    int i=10;

    printf("i=%d", i);

    {

    int i=20;

    printf("i=%d", i);

    i++;

    printf("i=%d", i);

    }

    printf("i=%d", i);

    }

  8. A.

     10 10 11 11

    B.

     10 20 21 21

    C.

     10 20 21 10

    D.

     10 20 21 20


  9. What will be the value of i and j after execution of following program?

    #include<stdio.h>

    void main()

    {

    int i, j;

    for(i=0,j=0;i<10,j<20;i++,j++){

    printf("i=%d %t j=%d", i, j);

    }

    }

  10. A.

     10 10

    B.

     10 20

    C.

     20 20

    D.

     Run time error


  11. What will be the output given program?

    #include<stdio.h>

    void main()

    {

    int i = -10;

    for(;i;printf("%d ", i++));

    }

  12. A.

     -10 to -1

    B.

     -10 to infinite

    C.

     -10 to 0

    D.

     Complier error


  13. What will be the output of the given program?

    #include<stdio.h>

    void main()

    {

    int a=11,b=5;

    if(a=5) b++;

    printf("%d %d", ++a, b++);

    }

  14. A.

     12 7

    B.

     5 6

    C.

     6 6

    D.

     6 7

    E.

     11 6


  15. What will be the output of the given program?

    #include<stdio.h>

    void main()

    {

    int value=0;

    if(value)

    printf("well done ");

    printf("examveda");

    }

  16. A.

     well done examveda

    B.

     examveda

    C.

     complier error

    D.

     None of these


  17. What will be the output of the given program?

    #include<stdio.h>

    void main()

    {

    int value1, value2=100, num=100;

    if(value1=value2%5) num=5;

    printf("%d %d %d", num, value1, value2);

    }

  18. A.

     100 100 100

    B.

     5 0 20

    C.

     5 0 100

    D.

     100 0 100

    E.

     100 5 100


  19. What will be the output of the given program?

    #include

    void main()

    {

    float num=5.6;

    switch(num){

    case 5:printf("5");

    case 6:printf("6");

    default : printf("0");

    break;

    }

    printf("%d", num);

    }

  20. A.

     5 5.600000

    B.

     6 5.600000

    C.

     0 5.600000

    D.

     Complier error