My Report

C Programming Practice Test 6


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

1. When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?

2. What will be the output of the following C code if following commands are used to run and if myfile does not exist?

    gcc -o test test.c
    ./test > myfile
    
    #include <stdio.h>
    int main(int argc, char **argv)
    {
        char c = 'd';
        putchar(c);
        printf(" %d\n", argc);
    } 

3. Which of the following is false about typedef?

4. Which of the following statement is true?

5. What is the use of getchar()?

6. Which of the following is not allowed?

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

    #include <stdio.h>
    int main()
    {
        int i = 10, j = 2;
        printf("%d\n", printf("%d %d ", i, j));
    } 

8. Which type of files can’t be opened using fopen()?

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

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

    #include <stdio.h>
    int main()
    {
        FILE *fp = stdout;
        int n;
        fprintf(fp, "%d ", 45);
        fprintf(stderr, "%d ", 65);
        return 0;
    } 

 

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.