C Questions

0 votes, 0 avg
268

C Questions

1 / 15

1. The parameter control string in the printf () is a C String that contains text to be __________

2 / 15

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

#include 

int main()
{
    float x = 23.456;
    printf("%.2f",x);
    return 0;
}

3 / 15

3. What is the use of symbol * in the control string as shown [=%[*][width] [modifiers] type=]?

4 / 15

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

#include 

int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%ld", sizeof(x)/sizeof(x[0]));
    return 0;
}

5 / 15

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

#include 

int main(){
    char grade = 'B';

    switch (grade) {
    case 'A':
        printf("Excellent!n");
    case 'B':
    case 'C':
        printf("Well donen");
    case 'D':
        printf("You passedn");
    case 'F':
        printf("Better try againn");
        break;
    default:
        printf("Invalid graden");
    }
}

6 / 15

6. Which of the following is true for the static variable?

7 / 15

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

    #include 

    void main()

    {

        int i = 0;

        while (i < 10)

        {

            i++;

            printf("hin");

            while (i < 8) 

            {

                i++;

                printf("hellon");

            }

        }

    }

8 / 15

8. Comment on the following 2 arrays with respect to P and Q.

       int *a1[8];

       int *(a2[8]);

       P. Array of pointers

       Q. Pointer to an array

9 / 15

9. How many times i value is checked in the following C program?

        #include 

        int main()

        {

            int i = 0;

            while (i < 3)

                i++;

            printf("In while loopn");

        }

10 / 15

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

11 / 15

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

#include 
void solve() {
    int a = 3;
    int res = a++ + ++a + a++ + ++a;
    printf("%d", res);
}
int main() {
solve();
return 0;
}

12 / 15

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

13 / 15

13. What is the output of C Program.?

int main()
{
    int a=14;
    
    while(a<20)
    {
        ++a;
        if(a>=16 && a<=18)
        {
            continue;
        }
        printf("%d ", a);
       
    }

    return 0;
}

14 / 15

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

#include 

int main()
{
    float x = 21.0;
    x %= 3.0;
    printf("%f",x);

    return 0;
}

15 / 15

15. What will fopen will return, if there is any error while opening a file?

Your score is

The average score is 30%

0%