0% found this document useful (0 votes)
5 views

bits[1] (1)

The document contains a series of multiple-choice questions and answers related to the C programming language, covering topics such as array declarations, function parameters, memory allocation, and data types. It includes questions about syntax, operators, and specific functions in C, along with their expected outputs. The answers to each question are provided, indicating the correct choice for each query.

Uploaded by

Mahaboob Saniya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

bits[1] (1)

The document contains a series of multiple-choice questions and answers related to the C programming language, covering topics such as array declarations, function parameters, memory allocation, and data types. It includes questions about syntax, operators, and specific functions in C, along with their expected outputs. The answers to each question are provided, indicating the correct choice for each query.

Uploaded by

Mahaboob Saniya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1.

Which keyword is used to make the array size optional in C language during array
declaration?
a)auto b)static c)extern d) register Ans:C

2. Which of the following is the correct syntax to send an array as a parameter to a C


function?
a)Bothfunc(&array)andfunc(*array);
b)Bothfunc(#array)andfunc(&array);
c)Bothfunc(array)andfunc(&array);
d) Both func(array[size]) and func(*array); Ans: C

3. An array in C cannot be initialized by which of the following statement?


a)chara[]=“Hello”;
b)chara[6]={};
c)chara[6]={0};
d)char a[6];
a = "Hello"; Ans: D

4.Which is an indirection operator among the following?


a)&
b)*
c)->
d) . Ans: B

5. Which of the following does not initialize ptr to null (assuming variable declaration
ofaasinta=0;)?
a)int*ptr=&a;
b)int*ptr=&a–&a;
c)int*ptr=a–a;
d) All of the mentioned Ans :A

6. __________ can never be sent by call-by-value? Ans: Array

7. Arguments that take input by user before running a program are called_________ Ans:
Command-Line arguments

8. What is the sizeof(char) in a 32-bit C compiler________ Ans: 1 Byte

9. __________is the default return type if it is not specified in function definition?

Ans: int

10. ____________ operator connects the structure name to its member name? Ans: dot
(.)operator
11. The value obtained in the function is given back to main by using ________ keyword.
Ans: return

12. What type of value does sizeof return__________ Ans: unsigned int

13. ___________header files must necessarily be included to use dynamic memory allocation
functions? Ans: stdlib.h

14. Functions in C are always _________ Ans: External

15. What will strcmp() function do? Ans: compares the string.

16. Local variables are stored in an area called ___________


a)Heap
b)Permanentstoragearea
c)Freememory
d) Stack Ans: D

17.Which function is used to allocate memory dynamically in C?


A)malloc()
B)calloc()
C)reserve()
D)new() Ans: A
18.What is the return type of the malloc() function?
A)int
B)void*
C)char*
D)float* Ans: B

19. A function which calls itself is called a ___ function.

a) Self Function
b) Auto Function
c) Recursive Function
d) Static Function Ans: C

20. What is the limit for number of functions in a C Program?

a) 16
b) 31
c) 32
d) No Limit Ans: D

21. ____________cannot be a structure member? Ans: Function

22. _________functions allocates multiple blocks of memory, each block of the same size?
Ans: calloc()
23. ____________keywords is used to define an alternate name for an already existing data
type? Ans: typedef

24. What is the return-type of the function sqrt() _________ Ans: double

25. _________ function will you choose to join two words. Ans: strcat()

26. Array sizes are optional during array declaration by using ______ keyword.

Ans: extern

27. _______ function tests for any character that is an uppercase letter. Ans: isupper()

28. What is the size of int *ptr in a 32-bit _________ Ans: 4

29. ______________ are themselves a collection of different data types?

Ans: structures

30. The______ function returns the number of characters that are present before the
terminating null character. Ans: strlen()

31. 1. Local variables are stored in an area called ___________ ANS:D

a) Heap

b) Permanent storage area

c) Free memory

d) Stack

32. 2. In the function malloc(), each byte of allocated space is initialized to zero. ANS:B

a) True

b) False

33. What will be the output of the following C code? ANS:B


#include<stdio.h>
#include<stdlib.h>
void main()
{
char *p = calloc(100, 1);
p = "welcome";
printf("%s\n", p);
}
a) error

b) welcome

c) memory location stored by the pointer

d) junk value

34. In the function realloc(), if the new size of the memory block is larger than the old size,
then the added memory ___________ ANS:D

a) is initialized to junk values

b) is initialized to zero

c) results in an error

d) is not initialized

35. The free() function frees the memory state pointed to by a pointer and returns
___________ ANS:C

a) the same pointer

b) the memory address

c) no value

d) an integer value

36. Which code from the given option return pointer to last occurrence of c in ch or NULL if
not present? ANS:B

a) char *strchr(ch, c)

b) char *strrchr(ch, c)

c) char *strncat(ch, c)

d) char *strcat(ch, c)

37. Is there any function declared as strstr()? ANS:A

a) true

b) false

38. What is the return-type of the function sqrt()? ANS:C

a) int
b) float

c) double

d) depends on the data type of the parameter

39. Which of the following does not initialize ptr to null (assuming variable declaration of a
as int a=0;)? ANS:A

a) int *ptr = &a;

b) int *ptr = &a – &a;

c) int *ptr = a – a;

d) All of the mentioned

40. What are the applications of a multidimensional array? ANS:D

a) Matrix-Multiplication

b) Minimum Spanning Tree

c) Finding connectivity between nodes

d) All of the mentioned

41. calloc() initialize memory with all bits set to zero. ANS:A

a) True

b) False

c) Depends on the compiler

d) Depends on the standard

42. One of the uses for function pointers in C is __________ ANS:D

a) Nothing

b) There are no function pointers in c

c) To invoke a function

d) To call a function defined at run-time

43. Functions in C are always _________ ANS:B

a) Internal
b) External

c) Both Internal and External

d) External and Internal are not valid terms for functions

44. What will be the data type returned for the following C function? ANS:B

#include <stdio.h>
int func()
{
return (double)(char)5.0;
}

a) char

b) int

c) double

d) multiple type-casting in return is illegal

45. What would happen if you create a file stdio.h and use #include “stdio.h”? ANS:B

a) The predefined library file will be selected

b) The user-defined library file will be selected

c) Both the files will be included

d) The compiler won’t accept the program

46. Can function definition be present in header files? ANS:A

a) Yes

b) No

c) Depends on the compiler

d) Depends on the standard

47. register keyword mandates compiler to place it in machine register. ANS:B

a) True

b) False

c) Depends on the standard


d) None of the mentioned

48. Register storage class can be specified to global variables. ANS:B

a) True

b) False

c) Depends on the compiler

d) Depends on the standard

49. Which of the following file extensions are accepted with #include? ANS:D

a) .h

b) .in

c) .com

d) All of the mentioned

50. C preprocessors can have compiler specific features. ANS:A

a) True

b) False

c) Depends on the standard

d) Depends on the platform

51. The size of a union is determined by the size of the __________ANS:C

a) First member in the union

b) Last member in the union

c) Biggest member in the union

d) Sum of the sizes of all members

52. Members of a union are accessed as________________ANS.C

a) union-name.member

b) union-pointer->member

c) both union-name.member & union-pointer->member


d) none of the mentioned

53. Which of the following uses structure? ANS:D

a) Array of structures

b) Linked Lists

c) Binary Tree

d) All of the mentioned

54. User-defined data type can be derived by___________ANS:D

a) struct

b) enum

c) typedef

d) all of the mentioned

55. Which operator connects the structure name to its member name?ANS:C

a) –

b) <-

c) .

d) Both <- and .

56. When compiler accepts the request to use the variable as a register?ANS:A

a) It is stored in CPU

b) It is stored in cache memory

c) It is stored in main memory

d) It is stored in secondary memory

57. Which data type can be stored in register?ANS:D

a) int

b) long

c) float
d) all of the mentioned

58. Which among the following is the correct syntax to declare a static variable register?
ANS:D

a) static register a;

b) register static a;

c) Both static register a; and register static a;

d) We cannot use static and register together

59. If the file name is enclosed in double quotation marks, then _________ANS:A

a) The preprocessor treats it as a user-defined file

b) The preprocessor treats it as a system-defined file

c) The preprocessor treats it as a user-defined file & system-defined file

d) None of the mentioned

60. Which of the following names for files not accepted?ANS:D

a) header.h.h

b) 123header.h

c) _head_er.h

d) None of the mentioned

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy