C Questions

0 votes, 0 avg
1

C Questions

1 / 15

1. The concept of two functions with same name is know as?

2 / 15

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

3 / 15

3. Which of the following is an exit controlled loop?

4 / 15

4. Which of the following is not a valid C variable name?

5 / 15

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

6 / 15

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

7 / 15

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


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

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. What is output of below program?


int main()
{
 int i,j;
 for(i = 0,j=0;i<5;i++)
 {
   printf("%d%d--",i,j);
 }
 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 is the default return type if it is not specified in function definition?

12 / 15

12. Which option should be selected to work the following C expression?

string p = "HELLO";

13 / 15

13. scanf() is a predefined function in______header file.

14 / 15

14. What is an example of iteration in C?

15 / 15

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

Your score is

The average score is 60%

0%