C Interview Questions 131-140

This post contains 131-140 questions of c program. It will helpful to solve c aptitude questions, c quiz , c objective type questions etc in interview.

131-140 Questions

Q1:
#define assert(cond) if(!(cond)) \
(fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\
__FILE__,__LINE__), abort())
void main()
{
    int i = 10;
    if(i==0)
        assert(i < 100);
    else
        printf("This statement becomes else for if in assert macro");
}
Answer:
No output

Q2:
What is the problem with the following code segment?
while ((fgets(receiving array,50,file_ptr)) != EOF) ;
Answer:
fgets returns a pointer.

Q3:
If a file is opened in r+ mode then 
a) reading is possible 
b) writing is possible 
c) it will be created if it does not exist 
d) appending is possible
Answer:

Q4:
If a file is opened in w+ mode then 
a) reading is possible 
b) writing is possible 
c) it will be created if it does not exist 
d) appending is possible
Answer:

Q5:
If a file is opened in r mode then 
a) reading is possible 
b) writing is possible 
c) it will be created if it does not exist 
d) appending is possible
Answer:  

Q6:
If a file is opened in a mode then 
a) reading is possible 
b) writing is possible 
c) it will be created if it does not exist 
d) appending is possible
Answer:

Q7:
ftell 
a) is a function 
b) gives the current file position indicator 
c) can be used to find the size of a file 
d) none of the above
Answer:

Q8:
Thefseekfunction 
a) needs 2 arguments 
b) makes rewind function unnecessary 
c) takes 3 arguments 
d) none of the above
Answer:

Q9:
rewind function takes __ number of arguments 
a) 1 
b) 2 
c) 3 
d) 0
Answer:

Q10:
fseek(fptr,0,0) is equivalent to 
a) ftell 
b) rewind 
c) a & b 
d) none of the above
Answer:

Comments are closed.