C Questions

0 votes, 0 avg
742

C Questions

1 / 15

1. What will be the output of the following C code?

        #include 

        int main()

        {

            enum {ORANGE = 5, MANGO, BANANA = 4, PEACH};

            printf("PEACH = %dn", PEACH);

        }

2 / 15

2. What type of array is generally generated in Command-line argument?

3 / 15

3. What will be the output of the following C program?

#include 

union values {
    int val1;
    char val2;
} myVal;

int main()
{
    myVal.val1 = 66;
    
    printf("val1 = %p", &myVal.val1);
    printf("nval2 = %p", &myVal.val2);
    
    return 0;
}

4 / 15

4. Property which allows to produce different executable for different platforms in C is called?

5 / 15

5. What will be the final values of i and j in the following C code?

    #include 

int x = 0;

int f()

{

if (x == 0)

return x + 1;

else

return x - 1;

}

int g()

{

return x++;

}

int main()

{

int i = (f() + g()) | g(); //bitwise or

int j = g() | (f() + g()); //bitwise or

}


                            

6 / 15

6. What will be the output of the following C code?

        #include 

        #include 

        int main()

        {

            char line[3];

            FILE *fp;

            fp = fopen("newfile.txt", "r");

            while (fgets(line, 3, fp))

            fputs(line, stdout);

            return 0;

        }

7 / 15

7. Identify X library function for line input and output in the following C code?

8 / 15

8. What is storage class for variable A in below code?


int main()
{
int A;
A = 10;
printf("%d", A);
return 0;
}

9 / 15

9. Which C keyword is used to extend the visibility of variables?

10 / 15

10. What does argc and argv indicate in command-line arguments?
(Assuming: int main(int argc, char *argv[]) )

11 / 15

11. What will be the output of the following code snippet?

#include 
void solve() {
    int ch = 2;
    switch(ch) {
        case 1: printf("1 ");
        case 2: printf("2 ");
        case 3: printf("3 ");
        default: printf("None");
    }
}
int main() {
    solve();
return 0;
}

12 / 15

12. Which statement is required to execute a block of code when the condition is false?

13 / 15

13. What will be the output of the following C code?

        #include 

        int main()

        {

            int x = 0;

            if (x == 1)

                if (x == 0)

                    printf("inside ifn");

                else

                    printf("inside else ifn");

            else

                printf("inside elsen");

        }

14 / 15

14. What is the output of C Program.?

int main()
{
    int a=10,b=20;
    
    if(a==9 AND b==20)
    {
        printf("Hurray..");
    }
    
    if(a==10 OR b==21)
    {
        printf("Theatre");
    }

    return 0;
}

15 / 15

15. What will be the output of the following code snippet?

#include 
void solve() {
    int first = 10, second = 20;
    int third = first + second;
    {
        int third = second - first;
        printf("%d ", third);
    }
    printf("%d", third);
}
int main() {
solve();
return 0;
}

Your score is

The average score is 38%

0%

Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.

Scroll to Top