c Objective Questions

Share Embed Donate


Short Description

c questions...

Description

1.Which of the following special symbol allowed in a variable name? A.

* (asterisk)

B.

C.

- (hyphen)

D.

| (pipeline)  _ (underscore)

2.Is there any difference in the following declarations? int myfun(int arr[]); int myfun(arr[20]); A.

Yes

B.

No

3.How many times "IndiaBIX" is get printed?

#include  int main() int main() { int x; int  x; for(x=-1; for (x=-1; xb ? c=30 : c=40;

B.

a>b ? c=30;

C.

max = a>b ? a>c?a:c:b>c?b:c

D.

return (a>b)?(a:b)

7.The keyword used to transfer control from a function back to the calling function is A.

switch

B.

Goto

C.

go back

D.

Return

8.How many times the program will print "IndiaBIX" ?

#include  int main() { printf("IndiaBIX"); main(); return 0; }

A.

Infinite times

B.

32767 times

C.

65535 times

D.

Till stack overflows

9.Can you combine the following two statements into one?

char *p; p = (char*) malloc(100);

A.

char p = *malloc(100);

B.

char *p = (char) malloc(100);

C.

char *p = (char*)malloc(100);

D.

char *p = (char *)(malloc*)(100);

10.What does the following declaration mean? int (*ptr)[10]; A.

ptr is array of pointers to 10 integers

B.

 ptr is a pointer to an array of 10 integers

C.

ptr is an array of 10 integers

D.

ptr is an pointer to array

11.What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? A.

The element will be set to 0.

B.

The compiler would report an error.

C.

The program may crash if some important data gets overwritten.

D.

The array size would appropriately grow.

12.If the two strings are identical, then strcmp() function returns A.

-1

B.

1

C.

0

D.

Yes

13.How will you free the allocated memory ? A.

remove(var-name);

B.

free(var-name);

C.

delete(var-name);

D.

dalloc(var-name);

14.What is the similarity between a structure, union and enumeration? A.

All of them let you define new values

B.

All of them let you define new data types

C.

All of them let you define new pointers

D.

All of them let you define new structures

15.What is the purpose of "rb" in fopen() function used below in the code?

FILE *fp; fp = fopen("source.txt", "rb");

A.

open "source.txt" in binary mode for reading

B.

open "source.txt" in binary mode for reading and writing

C.

Create a new file "source.txt" for reading and writing

D.

None of above

16.What does fp point to in the program ?

#include  int main() {

FILE *fp; fp=fopen("trial", "r"); return 0; }

A.

The first character in the file

B.

A structure which contains a char pointer which points to the first character of a file.

C.

The name of the file.

D.

The last character in the file.

17.What will be the output of the program?

#include  int main() { int y=128; const int x=y; printf("%d\n", x); return 0; }

A.

128

B.

Garbage value

C.

Error

D.

0

18.Specify the 2 library functions to dynamically allocate memory? A.

malloc() and memalloc()

B.

alloc() and memalloc()

C.

 malloc() and calloc()answer

D.

memalloc() and faralloc()

19.What is the output of: #include int main() { int x=40; { int x=20; printf("%d",x); } printf("%d",x); return 0; }

A.40 40

B.20 40 C.40 20 D.compilation error 20.when we use the case control structure? A. To choose one from multiple alternatives B. To switch from one instruction to another C. To make the execution fast D. None of the above

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF