Files and Preprocessors in C - Viva Interview for Engineering Freshers Basics Tutorials

1.Identify the token pasting operator?
a)+
b)++
c)#
d)##
ANSWER: D

2.What is the value of CAR in the following Statement?
enum vehicle
{BUS, SCOOTER = 2, CAR, TRAIN = 5, AEROPLANE = 6}
a)0
b)1
c)3
d)4
ANSWER: C
3.Given the following declaration identify the correct definition.
typedef struct node
{
int id;
char name[20];
};
a)node n;
b)NODE n;
c)typedef NODE n;
d)typedef node n;
ANSWER: B
More Readings
What happens When Interrupt Occurs
Difference Between Process and Thread
Difference Between RS232 and RS485 Communication Protocol
Differences between Mutex And Semaphore

4.Identify the correct statement 
1.The typedef defines synonym for an existing data type.
2.The typedef create a new data type that is not existing in C.
3.The typedef helps in easier modification of a portable program.
4.The typedef gives meaningful name to a data type.
a)Option 1, 3 and 4.
b)Option 1 and 4
c)Option 2 and 3
d)Option 2, 3 and 4
ANSWER: A

5.What is the output of the following code?
enum control
{
On, off, neutral
};
PRINTF(“%d”, off);
a)Compilation error
b)Execution error
c)5
d)1
ANSWER: A

6.What is the output of the following program?
#define MAX (x, y) ((x) > (y) ? (x) : (y))
main()
{
int x=5, y = 5;
printf(“maximum is %d”, MAX( ++x, ++y));
}
a)Maximum is 7
b)Maximum is 5
c)Maximum is 6
d)None
ANSWER: A

7.Which ANSI C function can be used to obtain a date string from structure *tm?
a)sttime(tm)
b)asctime(tm)
c)gmtime(tm)
d)strtime(tm)
ANSWER: B

8.Given the statement x = fopen(b, c);
what is b?
a)Pointer to character array which contains the file name.
b)File name within double quotes
c)Option a or b
d)None 
ANSWER: C

9.What is the output generated by the following code?
#define square (a) (a * a)
printf(“%d”, square (4 + 5));
a)81
b)4
c)29
d)None 
ANSWER: C

10.Which is more correct?
‘int main( int argc, char**argv)’
‘int main (int argc, char* argv[])’?
a)Both are equally wrong
b)Both are equally correct
c)Neither is correct
d)Int main(int argc, char** argv)
ANSWER: B

21.If the function definition of a program are in a file metric.c , where are the prototype declarations likely to be?
a)metric.cpp
b)metric.i
c)metric.exe
d)metric.h
ANSWER: D

22.Which of the following statements are correct?
a)A macro must always be defined in capital letters
b)Once preprocessing is over and the program is sent for the compilation the macros are removed from the expended source code
c)Macros have a local scope
d)In a macro call, the control is passed to the macro
ANSWER: B

23.Which of the following statement is correct about the code snippet given below?
# include <stdio.h>
Int main()
{
FILE *fp;
char str[80];
fp = fopen(“ABC.C”, “r”);
while( fgets( str, 80, fp) != eof)
puts( str);
return 0;
}
a)The code reports an error as L-value required
b)Code gives an output as garbage value
c)Code reports an error as undefined symbol eof
d)The code reads the content of the file if it is present and displays it on the screen.
ANSWER: C

24.What will be the output of the following code?
#include <stdio.h>
#define CUBE( Y) ( Y * Y * Y)
int main()
{
static int a, b = 3;
a = CUBE(++b)/b++;
printf(“a = %d b = %d”, a, b);
return 0;
}
a)a = 25 b = 7
b)a = 24 b = 7
c)a = 27 b = 6
d)a = 26 b = 9
ANSWER: A

25.What is the use of #pragma directive?
a)Used for making program portable
b)Used for expression evaluation
c)Used to turn off and on certain features
d)Both A & B
ANSWER: A

26.How will you define the macro AND and OR if the following C code snippet is to test whether a given character is alphabet or not?
#include <stdio.h>
#define LE <=
#define GE >=

int main()
{
char ch = ‘D’;
if(( ch GE 65 AND ch LE 90) OR (ch GE 97 AND ch LE 122))
printf(“Alphabet”);
else
printf(“Not an alphabet”);
return 0;
}
a) #define AND &&
#define OR ||
b) #define AND &
#define OR |
c) #define AND <
#define OR >
d) #define AND >>
#define OR <<
ANSWER: A

27.Referring to the sample code above, if a calling function has a char array variable string length 10 and a cust_rec structure variable record, what would be the correct call to testit?
void testit( struct cust_rec *sptr, char *s)
{……..; }
a)testit( &record, *string)
b)testit( &record, string)
c)testit( &record, &string)
d)testit( record, *string)
ANSWER: B

28.Stream oriented files are accessed through
a)System calls
b)Library functions
c)Linker
d)Loader
ANSWER: B

29.The function ftell( fptr) returns
a)The beginning position of the file represented by fptr
b)The end position of the file represented by fptr
c)The current position of the file represented by fptr
d)The middle position of the file represented by fptr
ANSWER: C

30.Identify the stringizing operator.
a)+
b)::
c)#
d)##
ANSWER: C

Related

Viva 8871199610581490355

Post a Comment

SPAMMING will not be Appreciated.

emo-but-icon

Hot in week

Recent

Comments

Our Channel

Contact Us

Name

Email *

Message *

item