C Programming 12

COEP
Lets Crack Online Exam

IT Interview Exam Questions: C Programming 12 (IT Interview Exam Question, IT Campus Placement)

Subject: C Programming 12

Part 12: List for questions and answers of C Language

 

Q1. Which among the following is odd one out?

a) printf

b) fprintf

c) putchar

d) scanf

 

Q2. For a typical program, the input is taken using

a) scanf

b) Files

c) Command-line

d) All of the mentioned

 

Q3. What does the following command line signify?prog1|prog2

a) It runs prog1 first, prog2 second

b) It runs prog2 first, prog1 second

c) It runs both the programs, pipes output of prog1 to input of prog2

d) It runs both the programs, pipes output of prog2 to input of prog1

 

Q4. What is the default return-type of getchar()?

a) char

b) int

c) char *

d) Reading character doesn’t require a return-type

 

Q5. The value of EOF is_____

a) -1

b) 0

c) 1

d) 10

 

Q6. stderr is similar to?

a) stdin

b) stdout

c) Both stdout and stdin

d) None of the mentioned 

 

Q7. What is the use of getchar()?

a) The next input character each time it is called

b) EOF when it encounters end of file

c) Both a & b

d) None of the mentioned

 

Q8. Which is true?

a) The symbolic constant EOF is defined in stdio.h

b) The value is -1

c) Both a & b

d) Only b

 

Q9. What is the return value of putchar()?

a) The character written

b) EOF if an error occurs

c) Nothing

d) Both a & b

 

Q10. Which is true?

a) The symbolic constant EOF is defined in stdio.h

b) The value is typically -1

c) Both a & b

d) Either a or b

 

Q11. To print out a and b given below, which of the following printf() statement will you use? float a=3.14; double b=3.14;

a) printf(“%f %lf”, a, b);

b) printf(“%Lf %f”, a, b);

c) printf(“%Lf %Lf”, a, b);

d) printf(“%f %Lf”, a, b);

 

Q12. Which is true about function tolower?

a) The function tolower is defined in

b) Converts an upper case letter to lower case

c) returns other characters untouched

d) None of the mentioned 

 

Q13. What is the output of this C code? int main() { char c = ‘d‘;putchar(c);}

a) Compile time error

b) Nothing

c) 0

d) Undefined behaviour

 

Q14. putchar(c) function/macro always outputs character c to the

a) screen

b) standard output

c) depends on the compiler

d) Depends on the standard

 

Q15. What is the output of this C code.(considering myfile exists)?

int main() { char c = ‘d’; putchar(c); }

a) Compile time error (after first command)

b) d in the myfile file

c) d on the screen

d) Undefined behaviour

 

Q16. What is the output of this C code. if myfile does not exist?

#include <stdio.h>

    int main(int argc, char **argv)

    {

        char c = ‘d’;

        putchar(c);

        printf(” %d\n”, argc);

    }

a) d 2 in myfile

b) d 1 in myfile

c) Depends on the system

d) Depends on the standard

 

Q17. Which of the following function can be used to terminate the main function from another function safely?

a) return(expr);

b) exit(expr);

c) abort();

d) Both b and c

 

Q18. What will be the content of ‘file.c’ ?

#include<stdio.h>

int main()

{

    FILE *fp1, *fp2;

    fp1=fopen(“file.c”, “w”);

    fp2=fopen(“file.c”, “w”);

    fputc(‘A’, fp1);

    fputc(‘B’, fp2);

    fclose(fp1);

    fclose(fp2);

    return 0;

}

a) B

b) AB

c) BB

d) Error in opening file ‘file1.c’ 

 

Q19. What will be the output of the program ?

#include<stdio.h>

int main()

{

    int k=1;

    printf(“%d == 1 is” “%s\n”, k, k==1?”TRUE”:”FALSE”);

    return 0;

}

a) k == 1 is TRUE

b) 1 == 1 is TRUE

c) 1 == 1 is FALSE

d) K == 1 is FALSE

 

Q20. What is the output of this C code (considering myfile exists)?

   #include <stdio.h>

    int main(int argc, char **argv)

    {

        char c = ‘d’;

        putchar(c);

        printf(” %d\n”, argc);

    }

a) d 2 in myfile

b) d 1 in myfile

c) d in myfile and 1 in screen

d) d in myfile and 2 in screen 

 

Part 12: List for questions and answers of C Language

 

Q1. Answer: d

 

Q2. Answer: d

 

Q3. Answer: c

 

Q4. Answer: b

 

Q5. Answer: a

 

Q6. Answer: a

 

Q7. Answer: c

 

Q8. Answer: c

 

Q9. Answer: d

 

Q10. Answer: c

 

Q11. Answer: a

 

Q12. Answer: d

 

Q13. Answer: b

 

Q14. Answer: b

 

Q15. Answer: c

 

Q16. Answer: b

 

Q17. Answer: b

 

Q18. Answer: a

 

Q19. Answer: b

 

Q20. Answer: b