You are on page 1of 8

5.0 one of elements of a structure can be a pointer to the same structure. A.

True
etan said: (Thu, Oct 13, 2011 02:13:31 AM) used.

B.False
Yes, while creating linked list self referential structure is

For eg.

struct node { int data; struct node *next; //self referential structures }

11. scanf() or atoi() function can be used to convert a string like "436" in to integer. A.Yes B.No

Workspace

13.Bitwise | can be used to set a bit in number. A.Yes 6. What will be the output of the program ?
#include<stdio.h> int main() { char *str; str = "%d\n"; str++; str++; printf(str-2, 300); return 0; }

B.No

A.No output C. 3 Answer: Option D Learn more problems on : Pointers Discuss about this problem : Discuss in Forum

B. 30 D.300

Twice str is incremented n then when we do str-2, it is again pointing to starting position. So str contains "%d\n".

So printf statement would be like printf("%d\n",300);

Hence output will be 300.

15. What will be the output of the program?


#include<stdio.h> int main() { int i=1; if(!i) printf("IndiaBIX,"); else { i=0; printf("C-Program"); main(); } return 0; }

A.prints "IndiaBIX, C-Program" infinitely B. prints "C-Program" infinetly C. prints "C-Program, IndiaBIX" infinitely

D.Error: main() should not inside else statement

Macro calls and function calls work exactly similarly. A.True B.False

18. Is it true that too many recursive calls may result into stack overflow? A.Yes B.No

Workspace

17.In which stage the following code #include<stdio.h> gets replaced by the contents of the file stdio.h A.During editing C. During execution

B. During linking D.During preprocessing

3. Point out the error in the following program.


#include<stdio.h> #include<stdarg.h> fun(...); int main() { fun(3, 7, -11.2, 0.66); return 0; } fun(...) { va_list ptr; int num; va_start(ptr, n); num = va_arg(ptr, int); printf("%d", num); }

A.Error: fun() needs return type

B. Error: ptr Lvalue required C. Error: Invalid declaration of fun(...) D.No error Answer: Option C Explanation: There is no fixed argument in the definition fun() Learn more problems on : Variable Number of Arguments Discuss about this problem : Discuss in Forum 7. What will be the output of the program?
#include<stdio.h> int main() { printf("%d >> %d %d >> %d\n", 4 >> 1, 8 >> 1); return 0; }

A.4 1 8 1 B. 4 >> 1 8 >> 1 C. 2 >> 4 Garbage value >> Garbage value D.2 4 Answer: Option C Learn more problems on : Bitwise Operators
4 = 0100 now shift to right 1 time. It will become 0010 = 2.

8 = 1000 now shift to right 1 time. It will become 0100 = 4.

Rest is garbage, so the answer is C.

10. Is standard library a part of C language? A.Yes Answer: Option B Explanation: The C standard library consists of a set of sections of the ISO C standard which describe a collection of header files and library routines used to implement common operations, such as input/output and string handling, in the C programming language. The C standard library is an interface standard described by a document; it is not an actual library of software routines available for linkage to C programs. Learn more problems on : Library Functions Will the program outputs "IndiaBIX.com"?
#include<stdio.h> #include<string.h> int main() { char str1[] = "IndiaBIX.com"; char str2[20]; strncpy(str2, str1, 8); printf("%s", str2); return 0; }

B.No

A.Yes B.No View Answer Online Compiler Report Discuss in Forum 3. The itoa function can convert an integer in decimal, octal or hexadecimal form to a string. A.Yes B.No Answer & Explanation Answer: Option A Explanation: itoa() takes the integer input value input and converts it to a number in base radix. The resulting number a sequence of base-radix digits.

Example:
/* itoa() example */ #include <stdio.h> #include <stdlib.h> int main () { int no; char buff [50]; printf ("Enter number: "); scanf ("%d",&no); itoa (no,buff,10); printf ("Decimal: %s\n",buff); itoa (no,buff,2); printf ("Binary: %s\n",buff); itoa (no,buff,16); printf ("Hexadecimal: %s\n",buff); return 0; }

Output: Enter a number: 1250 Decimal: 1250 Binary: 10011100010 Hexadecimal: 4e2

14. What will be the output of the program, if a short int is 2 bytes wide?
#include<stdio.h> int main() { short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0; }

A.1 ... 65535 C. No output Answer: Option A Explanation:

B. Expression syntax error D.0, 1, 2, 3, 4, 5

for(i<=5 && i>=-1; ++i; i>0) so expression i<=5 && i>=-1 initializes for loop. expression ++i is the loop condition. expression i>0 is the increment expression. In for( i <= 5 && i >= -1; ++i; i>0) expression i<=5 && i>=-1 evaluates to one. Loop condition always get evaluated to true. Also at this point it increases i by one. An increment_expression i>0 has no effect on value of i.so for loop get executed till the limit of integer (ie. 65535) Learn more problems on : Control Instructions

20. Macro calls and function calls work exactly similarly. A.True Answer: Option B Explanation: False, A macro just replaces each occurrence with the code assigned to it. e.g. SQUARE(3) with ((3)*(3)) in the program. A function is compiled once and can be called from anywhere that has visibility to the funciton. Learn more problems on : C Preprocessor B.False

You might also like