My Report (&Account)

C Programming Online Test


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

Here is the complete list of test quizzes on C Programming.

1. Select the correct declaration of setjmp().

Question 1 of 50

2. A variable declared in a function can be used in main().

Question 2 of 50

3. The following C code results in an error. State whether true or false.

#include<stdio.h>
#include<time.h>
int main()
{
    struct tm *local;
    time_t t;
    t=time(NULL);
    local=asctime(localtime(&t));
    printf("%d",local->tm_wday);
    return 0;
}

Question 3 of 50

4. If the user enters 1 3.2 s, what value will be returned by the scanf()?

scanf("%d %f %c", &s1, &s2, &s3);

Question 4 of 50

5. Loss in precision occurs for typecasting from____________

Question 5 of 50

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

    #include <stdio.h>
    struct temp
    {
        int a;
    } s;
    void change(struct temp);
    main()
    {
        s.a = 10;
        change(s);
        printf("%d\n", s.a);
    }
    void change(struct temp s)
    {
        s.a = 1;
    } 

Question 6 of 50

7. HUGE_VAL macro is used when the output of the function may not be ___________

Question 7 of 50

8. What will be the output of the following C statement?

int ungetc(int c, FILE *fp)

Question 8 of 50

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

    #include <stdio.h>
    struct point
    {
        int x;
        int y;
    };
    void foo(struct point*);
    int main()
    {
        struct point p1[] = {1, 2, 3, 4, 5};
        foo(p1);
    }
    void foo(struct point p[])
    {
        printf("%d %d\n", p->x, (p + 2)->y);
    } 

Question 9 of 50

10. When the pointer is NULL, then the function realloc is equivalent to the function ___________

Question 10 of 50

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

    #include <stdio.h>
    typedef struct p
    {
        int x, y;
    }k = {1, 2};
    int main()
    {
        p k1 = k;
        printf("%d\n", k1.x);
    } 

Question 11 of 50

12. Which macro can be used to detect and report exceptional conditions?

Question 12 of 50

13. What is the type declared by the header file signal.h?

Question 13 of 50

14. log(x) function defined in math.h header file is __________

Question 14 of 50

15. User-defined data type can be derived by___________

Question 15 of 50

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

    #include <stdio.h>
    int main()
    {
        int i = 0;
        while (i < 2)
        {
            if (i == 1)
                break;
                i++;
                if (i == 1)
                    continue;
                    printf("In while loop\n");
        }
        printf("After loop\n");
    } 

Question 16 of 50

17. What is the difference between %e and %g?

Question 17 of 50

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

    #include <stdio.h>
    int main()
    {
        if (~0 == 1)
            printf("yes\n");
        else
            printf("no\n");
    } 

Question 18 of 50

19. In linux, apart from including math header file, the program is successfully executed by which of the following?

Question 19 of 50

20. What is the first argument in command line arguments?

Question 20 of 50

21. If the file name is enclosed in double quotation marks, then _________

Question 21 of 50

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

    #include <stdio.h>
    union u
    {
        struct p
        {
            unsigned char x : 2;
            unsigned int y : 2;
        };
        int x;
    };
    int main()
    {
        union u u;
        u.p.x = 2;
        printf("%d\n", u.p.x);
    } 

Question 22 of 50

23. Comment on the output of the following C code.

    #include <stdio.h>
    int main()
    {
        int i, n, a = 4;
        scanf("%d", &n);
        for (i = 0; i < n; i++)
            a = a * 2;
    } 

Question 23 of 50

24. Property of the external variable to be accessed by any source file is called by the C90 standard as __________

Question 24 of 50

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

    #include <stdio.h>
    int main()
    {
        char *str = "hello world";
        char strc[] = "good morning india\n";
        strcpy(strc, str);
        printf("%s\n", strc);
        return 0;
    } 

Question 25 of 50

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

void *memset(void *c, int c, size-t n) 
unsigned char ch = c;
unsigned char *su;
for (su = s; 0 < n; ++su, --n)
<br>
*su = ch;
<br>

Question 26 of 50

27. Which of the following is not an example of big endian machines?

Question 27 of 50

28. What is the return value of getc()?

Question 28 of 50

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

    #include <stdio.h>
    int *i;
    int main()
    {
        if (i == 0)
            printf("true\n");
        return 0;
    } 

Question 29 of 50

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

    #include <stdio.h>
    void main()
    {
        int k = 0;
        double b = k++ + ++k + k--;
        printf("%d", k);
    } 

Question 30 of 50

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

    #include <stdio.h>
    int main()
    {
        int i = 1;
        if (i++ && (i == 1))
            printf("Yes\n");
        else
            printf("No\n");
    } 

Question 31 of 50

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

    #include <stdio.h>
    int *f();
    int main()
    {
        int *p = f();
        printf("%d\n", *p);
    }
    int *f()
    {
        int j = 10;
        return &j;
    }

Question 32 of 50

33. How many times while loop condition is tested in the following C code snippets, if i is initialized to 0 in both the cases?

while (i < n)
         i++;
    ————-
    do
         i++;
    while (i <= n);

Question 33 of 50

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

    #include<stdio.h>
    int main()
    {
        int a = 1, b = 2, c = 3, d = 4, e;
        e = c + d = b * a;
        printf("%d, %d\n", e, d);
    } 

Question 34 of 50

35. Which of the given statement is not true with respect to void longjmp( jmp-buf env, int val)?

Question 35 of 50

36. What will be the output for the given code printf(“\n The number is %07d”,1212);

Question 36 of 50

37. 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

Question 37 of 50

38. What is the problem in the following C declarations?

   int func(int);
   double func(int);
   int func(float);

Question 38 of 50

39. Which function will return the current file position for stream?

Question 39 of 50

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

#define display(a) #a
main()
{
    printf(display("56#7"));
}

Question 40 of 50

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

    #include <stdio.h>
    double var = 8;
    int main()
    {
        int var = 5;
        printf("%d", var);
    }

Question 41 of 50

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

    #include <stdio.h>
    int *f();
    int main()
    {
        int *p = f();
        printf("%d\n", *p);
    }
    int *f()
    {
        int *j = (int*)malloc(sizeof(int));
        *j = 10;
        return j;
    }

Question 42 of 50

43. What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)

    #include <stdio.h>
    void main()
    {
        int ch;
        printf("enter a value between 1 to 2:");
        scanf("%d", &ch);
        switch (ch, ch + 1)
        {
           case 1:
              printf("1\n");
              break;
           case 2:
              printf("2");
              break;
        }
    } 

Question 43 of 50

44. What are the first and second arguments of fopen?

Question 44 of 50

45. Point out the error (if any) in the following C code?

#include <stdlib.h>
#include <stdio.h>
int main(void)
{
    int* p = NULL;
    struct S *s = NULL;
    void(*f)(int, double) = NULL;
    char *ptr = malloc(15);
    if (ptr == NULL) printf("Out of memory");
    free(ptr);
}

Question 45 of 50

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

    #include <stdio.h>
    int main()
    {
        int i = 10;
        int *const p = &i;
        foo(&p);
        printf("%d\n", *p);
    }
    void foo(int **p)
    {
        int j = 11;
        *p = &j;
        printf("%d\n", **p);
    } 

Question 46 of 50

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

    #include <stdio.h>
    int const print()
    {
        printf("Sanfoundry.com");
        return 0;
    }
    void main()
    {
        print();
    }

Question 47 of 50

48. Which of the following macros is defined under the header limits.h?

Question 48 of 50

49. setvbuf() and setbuf() function controls buffering for the stream.

Question 49 of 50

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

    #include <stdio.h>
    void f(int);
    void (*foo)(float) = f;
    int main()
    {
        foo(10);
    }
    void f(int i)
    {
        printf("%d\n", i);
    } 

Question 50 of 50


 

Topic wise Test Quizzes on C Programming

C Programming tests, quizzes, and exams are great ways to learn and test your C programming skills. Whether you’re a beginner or experienced, challenge and boost your confidence with our engaging online quizzes on C Basics, Data Types, Operators, Expression, Loops, Variables, Pointers, Array, Functions, Structure and Union. Start the C online test now!



C Programming Certification Test

C Programming Certification Test is a free certification exam. However, you need to score an A grade in each of the "Certification Level Tests 1 to 10" to be eligible to take part in this certification test. So, take all the "10 Tests" starting from Certification Level 1 upto Level 10, before taking the final Certification test.


Level 1 to 10 Tests:
Total Questions: 25, Total Time: 30 min, Correct Answer: 2 points, Wrong Answer: -1 point

Certification Test:
Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

C Programming Internship Test

If you scored either Grade A* or Grade A in our C Programming Internship Test, then you can apply for Internship at Sanfoundry in C Programming.


Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

C Programming Job Test

It is designed to test and improve your skills for a successful career, as well as to apply for jobs.


Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

Note: Before you get started on these series of online tests, you should practice our collection of 1000 MCQs on C Programming .

Sanfoundry Scoring & Grading System

Sanfoundry tests and quizzes are designed to provide a real-time online exam experience. Here is what you need to know about them.

  • Scoring System: You get 2 points for each correct answer but lose 1 point for every wrong answer.
  • Grading System: Your grade depends on your final score and can be one of the following:

    • Grade A* - Genius (100%)
    • Grade A - Excellent (80% to 99%)
    • Grade B - Good (60% to 80%)
    • Grade C - Average (40% to 60%)
    • Grade D - Poor (0% to 40%)
advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.