C Questions

0 votes, 0 avg
737

C Questions

1 / 15

1. What will be the output of the following C code if following commands are used to run (considering myfile exists)?

2 / 15

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

3 / 15

3. Which of the following is not a storage class specifier in C?

4 / 15

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

5 / 15

5. 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]);

        }

6 / 15

6. double ______ (double x, double y) computes the floating-point remainder of x/y.

7 / 15

7. The standard header _______ is used for variable list arguments (…) in C.

8 / 15

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

9 / 15

9. What will be the output of the following C code considering the size of a short int is 2, char is 1 and int is 4 bytes?

        #include 

        int main()

        {

            short int i = 20;

            char c = 97;

            printf("%d, %d, %dn", sizeof(i), sizeof(c), sizeof(c + i));

            return 0;

        }

10 / 15

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

       #include 
        int main()
        {
            int i = 0;
            do
            {
               i++;
                if (i == 2)
                    continue;
                    printf("In while loop ");
            } while (i < 2);
            printf("%dn", i);

        }

11 / 15

11. What does the following program print?

#include
void f(int *p, int *q)
{
  p = q;
 *p = 2;
}
int i = 0, j = 1;
int main()
{
  f(&i, &j);
  printf("%d %d n", i, j);
  getchar();
  return 0;
}

12 / 15

12. What will happen if a header file is included in a program twice?

13 / 15

13. What is an example of iteration in C?

14 / 15

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

15 / 15

15. 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");

        }

Your score is

The average score is 38%

0%

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

Scroll to Top