C Programming and Problem Solving Questions and Answers 351 to 360

C Programming and Problem Solving

Questions 351 to 360



351.
Find the output of the following program
int main()
{
increment();
increment();
increment();
}
increment()
{
static int i=0;
i=i+1;
printf(“%d”,i);
}
(a)
0,0,1
(b)
1,1,1
(c)
2,2,2
(d)
3,3,3
(e)
1,2,3.
352.
What is the value of a in following expression a=(3<5)?(4<6)?6:7:8;?
(a)
4
(b)
7
(c)
8
(d)
6
(e)
0.
353.
The declaration int (*a)[8] is
(a)
An array of pointers
(b)
A pointer to an array
(c)
A pointer to a function
(d)
Function returning pointer
(e)
Function taking 8 integer pointers.
354.
What is dangling pointer?
(a)
A pointer points to allocated memory
(b)
A pointer points to deallocated memory
(c)
A pointer points to function
(d)
A pointer points to variable
(e)
A pointer points to another pointer.
355.
What is difference between *p++ and ++*p?
(a)
Both increment values
(b)
Both increment addresses
(c)
First one increment address second one increment value
(d)
First one increment value second one  increment address
(e)
Syntax error.
356.
int a = 10, b = 20, c = 30, d = 40;
printf(" %d ",  a ^ b & c | d );
What is the output for the above code?
(a)
62
(b)
63
(c)
52
(d)
53
(e)
Error.
357.
Which one of the following functions is the correct choice for moving blocks of binary data that are of arbitrary size and position in memory?          
(a)
memmove( )
(b)
memset( )
(c)
strncpy( )
(d)
strcpy( )
(e)
memcpy( ).
358.
What is difference between gets() and fgets()?
(a)
Both are functions
(b)
Both are macros
(c)
gets is macro and fgets is function
(d)
gets is function and fgets is macro
(e)
Both are system calls.
359.
Find the output of the following program
union emp
{
int  eno;
char name[10];
int sal;
};
struct  emp1
{
int  eno;
char name[10];
int sal;
};
int main()
{
struct emp e1;
union emp1 e2;
printf(“%d%d”sizeof(e1),sizeof(e2));
}
(a)
14 ,14
(b)
10 ,10
(c)
10 ,14
(d)
14 ,10
(e)
12 ,14.
360.
What is the Difference between open() and fopen() function?
(a)
No difference both are same
(b)
Open  function open file with stream fopen function open file with out streams
(c)
Open  function open file without stream fopen function open file with streams
(d)
Open function open file files and fopen open directories
(e)
Open function takes two arguments fopen function takes three arguments.

Answers



351.
Answer : (e)
Reason  :       static variables are initialize only once and life of variable exist b
etween two function calls
352.
Answer : (d)
Reason  :       ?: are ternary operators.
353.
Answer : (b)
Reason  :       a is a pointer points to array of 10 integers.
354.
Answer : (b)
Reason  :       Dangling pointer points to dealloated memory area .
355.
Answer : (c)
Reason  :       *p++ is equal to *(p++) and ++*p equal to ++(*p).
356.
Answer : (a)
Reason  :       ^ is XOR operator & AND operator | OR operator
357.
Answer : (a)
Reason  :       memory managemt functions operate on block of memory area
358.
Answer : (c)
Reason  :       gets  is macro and fgets  is function.
359.
Answer : (d)
Reason  :       structure allocate memory for all the structure elements
 but unions allocate memory for the element which is having maximum size
360.
Answer : (c)
Reason  :       open function open file without streams but fopen
function open file with streams


<< Prev 1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36... 



1 comment :