C Questions

0 votes, 0 avg
759

C Questions

1 / 15

1. What is the format identifier for “static a = 20.5;”?

2 / 15

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

        #include 

        struct student

        {

            int no = 5;

            char name[20];

        };

        void main()

        {

            struct student s;

            s.no = 8;

            printf("hello");

        }

3 / 15

3. Libray function getch() belongs to which header file?

4 / 15

4. How are String represented in memory in C?

5 / 15

5. Choose a correct statement about C language break; statement.

6 / 15

6. The syntax of the scanf() is scanf(“control string “, arg1,arg2,arg3,….,argn); the prototype of control string is ____________

7 / 15

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

        #include 

        void main()

        {

            int a[2][3] = {1, 2, 3, , 4, 5};

            int i = 0, j = 0;

            for (i = 0; i < 2; i++)

            for (j = 0; j < 3; j++)

            printf("%d", a[i][j]);

        }

8 / 15

8. Which of the following is the correct syntax to declare a 3 dimensional array using pointers?

9 / 15

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

10 / 15

10. 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;
}

11 / 15

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

12 / 15

12. What is output of below program?


int main()
{
int i,j,count;
count=0;
for(i=0; i<5; i++);
{ 
for(j=0;j<5;j++);
{
    count++;
}
}
printf("%d",count);
return 0;
}

13 / 15

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

#include 
void solve() {
    int a[] = {1, 2, 3, 4, 5};
    int sum = 0;
    for(int i = 0; i < 5; i++) {
        if(i % 2 == 0) {
            sum += *(a + i);
        }
        else {
            sum -= *(a + i);
        }
    }
    printf("%d", sum);
}
int main() {
solve();
return 0;
}

14 / 15

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

        #include 

        int main()

        {

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

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

        }

15 / 15

15. Is initialisation mandatory for local static variables?

Your score is

The average score is 38%

0%

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

Scroll to Top