MCQs > IT & Programming > C Programming MCQs > Basic C Programming MCQs

Basic C Programming MCQ

1. When a structure is passed ________ to a function, its members are not copied.

Answer

Correct Answer: By reference

Note: This Question is unanswered, help us to find answer for this one

2. If a condition in a post-test loop can never be met, the loop is an _________ loop.

Answer

Correct Answer: Infinite loop

Note: This Question is unanswered, help us to find answer for this one

3. An array name and index are separated using ____.

Answer

Correct Answer: Square brackets

Note: This Question is unanswered, help us to find answer for this one

4. The dynamic memory allocation functions are defined in which system header file ?

Answer

Correct Answer: Stdlib.h

Note: This Question is unanswered, help us to find answer for this one

5. Void pointer vptr is assigned the address of float variable g. What is a valid way to dereference vptr to assign its pointed value to a float variable named f later in the program? float g; void *vptr=&g;

Answer

Correct Answer: F=_(float _)vptr;

Note: This Question is unanswered, help us to find answer for this one

6. What does the ctype tolower() function do?

Answer

Correct Answer: It converts an uppercase letter of the alphabet to lowercase.

Note: This Question is unanswered, help us to find answer for this one

7. What standard data type provides the smallest storage size and can be used in computations?

Answer

Correct Answer: Char

Note: This Question is unanswered, help us to find answer for this one

8. What is the member access operator for a structure?

Answer

Correct Answer: .

Note: This Question is unanswered, help us to find answer for this one

9. What is not one of the basic data types in C

Answer

Correct Answer: Array

Note: This Question is unanswered, help us to find answer for this one

10. Which line of code, after execution, results in i having the value of 1?

Answer

Correct Answer: For(i=1; i==10; i++);

Note: This Question is unanswered, help us to find answer for this one

11. Which is not a storage class specifier?

Answer

Correct Answer: Intern

Note: This Question is unanswered, help us to find answer for this one

12. Which operator is used to access the address of a variable?

Answer

Correct Answer: &

Note: This Question is unanswered, help us to find answer for this one

13. Describe the relationship between lvalue and rvalue.

Answer

Correct Answer: An lvalue may appear on the left-hand or right-hand side of an assignment; an rvalue may appear only on the right-hand side.

Note: This Question is unanswered, help us to find answer for this one

14. A Stack data structure allows all data operations at one end only, making it what kind of an implementation?

Answer

Correct Answer: LIFO

Note: This Question is unanswered, help us to find answer for this one

15. By default, C Functions are what type of functions?

Answer

Correct Answer: Library

Note: This Question is unanswered, help us to find answer for this one

16. The main loop structures in C programming are the for loop, the while loop, and which other loop?

Answer

Correct Answer: Do...while

Note: This Question is unanswered, help us to find answer for this one

17. Directives are translated by the?

Answer

Correct Answer: Pre-processor

Note: This Question is unanswered, help us to find answer for this one

18. File input and output (I/O) in C is done through what?

Answer

Correct Answer: Function calls

Note: This Question is unanswered, help us to find answer for this one

19. What does the strcmp(str1, str2); function return?

Answer

Correct Answer: 0 if str1 and str2 are the same, a negative number if str1 is less than str2, a positive number if str1 is greater than str2

Note: This Question is unanswered, help us to find answer for this one

20. File input and output (I/O) in C is heavily based on the way it is done ___?

Answer

Correct Answer: In Unix

Note: This Question is unanswered, help us to find answer for this one

21. Compile time errors are static errors that can be found where in the code?

Answer

Correct Answer: In declarations and definitions

Note: This Question is unanswered, help us to find answer for this one

22. What is an alternative way to write the expression (*x).y?

Answer

Correct Answer: X->y

Note: This Question is unanswered, help us to find answer for this one

23. What is the expression player->name equivalent to?

Answer

Correct Answer: (\*player).name

Note: This Question is unanswered, help us to find answer for this one

24. What is not a valid command with this declaration? char *string[20] = { "one", "two", "three"};

Answer

Correct Answer: printf("%s", string[1][2]);

Note: This Question is unanswered, help us to find answer for this one

25. What is the difference between scanf() and sscanf() functions?

Answer

Correct Answer: The scanf() function reads formatted data from the keyboard; The sscanf() function reads formatted input from a string.

Note: This Question is unanswered, help us to find answer for this one

26. A union allows you to store different ___ in the same ___.

Answer

Correct Answer: Data types; Memory space

Note: This Question is unanswered, help us to find answer for this one

27. By default c uses the call by value method to pass arguments to functions. How can you invoke the call by reference method?

Answer

Correct Answer: By using pointers

Note: This Question is unanswered, help us to find answer for this one

28. When is memory for a variable allocated?

Answer

Correct Answer: During the declaration of the variable

Note: This Question is unanswered, help us to find answer for this one

29. In C language what are the basic building blocks that are constructed together to write a program?

Answer

Correct Answer: Tokens

Note: This Question is unanswered, help us to find answer for this one

30. Which function do you use to deallocate memory?

Answer

Correct Answer: Free()

Note: This Question is unanswered, help us to find answer for this one

31. In which segment does dynamic memory allocation takes place?

Answer

Correct Answer: Heap

Note: This Question is unanswered, help us to find answer for this one

32. C treats all devices, such as the display and the keyboard, as files. Which files opens automatically when a program executes?

Answer

Correct Answer: Stdout

Note: This Question is unanswered, help us to find answer for this one

33. What is optional in a function declaration?

Answer

Correct Answer: Parameter names

Note: This Question is unanswered, help us to find answer for this one

34. In this code sample, what is not a problem for C compiler? main(){ constant int PI = 3.14; printf("%f\n", pi);}

Answer

Correct Answer: The value of PI needs to be set to 3.141593, not 3.14

Note: This Question is unanswered, help us to find answer for this one

35. What is not one of the reserved words in standard C?

Answer

Correct Answer: Typeof

Note: This Question is unanswered, help us to find answer for this one

36. A C header file is a file with extension .h that contains function declarations and macro definitons to be shared between several source files. Header files are listed using the preprocessing directive #include, and can have one of the following formats: #include or #include "fileB". What is the difference between these two formats?

Answer

Correct Answer: The preprocessor will try to locate the fileA in a predetermined directory path. It will try to locate fileB in the same directory as the source file along with a custom directory path.

Note: This Question is unanswered, help us to find answer for this one

37. A pointer to void named vptr, has been set to point to a floating point variable named g. What is the valid way to dereference vptr to assign its pointed value to a float variable named f later in this program? float g; void *vptr=&g;

Answer

Correct Answer: F = *(float *)vptr;

Note: This Question is unanswered, help us to find answer for this one

38. What does the declaration of variable c2 demonstrate? main(){ char c1 ='a'; char c2 = c1+10;}

Answer

Correct Answer: Character arithmetic

Note: This Question is unanswered, help us to find answer for this one

39. What is the name for calling a function inside the same function?

Answer

Correct Answer: Recursion

Note: This Question is unanswered, help us to find answer for this one

40. Each array element occupies an area in memory next to, or ____, the others.

Answer

Correct Answer: Contiguous to

Note: This Question is unanswered, help us to find answer for this one

41. Many programming languages include a string operation called __________.

Answer

Correct Answer: Concatenation

Note: This Question is unanswered, help us to find answer for this one

42. A(n) ____ loop executes a predetermined number of times.

Answer

Correct Answer: Definite

Note: This Question is unanswered, help us to find answer for this one

43. You may define a __________ in the initialization expression of a for loop.

Answer

Correct Answer: Variable.

Note: This Question is unanswered, help us to find answer for this one

44. When an array is passed to a function, it is actually ________ the array that is/are passed.

Answer

Correct Answer: The starting memory address of

Note: This Question is unanswered, help us to find answer for this one

45. After a program is coded, it must be ____________.

Answer

Correct Answer: Tested

Note: This Question is unanswered, help us to find answer for this one

46. A ________ value in a loop can be either a positive or a negative number.

Answer

Correct Answer: Step

Note: This Question is unanswered, help us to find answer for this one

47. Function strcmp returns __________ if its first argument is equal to its second argument.

Answer

Correct Answer: Specifically 0

Note: This Question is unanswered, help us to find answer for this one

48. Objects in an array are accessed with ________, just like any other data type in an array.

Answer

Correct Answer: Subscripts

Note: This Question is unanswered, help us to find answer for this one

49. Common ides include visual studio and ____.

Answer

Correct Answer: Eclipse

Note: This Question is unanswered, help us to find answer for this one

50. Pointers are variables that contain __________ as their values.

Answer

Correct Answer: Memory addresses

Note: This Question is unanswered, help us to find answer for this one

51. Functions that do not have a return type are called ____ functions.

Answer

Correct Answer: Void

Note: This Question is unanswered, help us to find answer for this one

52. An inner loop goes through all of its iterations for every single iteration of the ________ loop.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

53. A two-dimensional array contains two dimensions: ____.

Answer

Correct Answer: Height and width.

Note: This Question is unanswered, help us to find answer for this one

54. ________ is a construct that defines objects of the same type.

Answer

Correct Answer: Inline function

Note: This Question is unanswered, help us to find answer for this one

55. ________ functions may have the same name, as long as their parameter lists are different.

Answer

Correct Answer: Two or more

Note: This Question is unanswered, help us to find answer for this one

56. The -- operator ________.

Answer

Correct Answer: Subtracts one from the value of its operand.

Note: This Question is unanswered, help us to find answer for this one

57. In any program that uses the cin object, you must include the ________.

Answer

Correct Answer: Iostream header file

Note: This Question is unanswered, help us to find answer for this one

58. You can use the ____ operator to increment or decrement the value of an enumeration type.

Answer

Correct Answer: Cast

Note: This Question is unanswered, help us to find answer for this one

59. With pointer variables, you can ________ manipulate data stored in other variables.

Answer

Correct Answer: Indirectly

Note: This Question is unanswered, help us to find answer for this one

60. When you work with a dereferenced pointer, you are actually working with ________.

Answer

Correct Answer: The actual value of the variable whose address is stored in the pointer variable

Note: This Question is unanswered, help us to find answer for this one

61. When you dereference an object pointer, use the ________.

Answer

Correct Answer: -> operator

Note: This Question is unanswered, help us to find answer for this one

62. When you write a program that stores a value in a variable, you are using ____ storage.

Answer

Correct Answer: Temporary

Note: This Question is unanswered, help us to find answer for this one

63. When a character is stored in memory, it is actually the ________ that is stored.

Answer

Correct Answer: Unicode number

Note: This Question is unanswered, help us to find answer for this one

64. Value is a function of ___________ and ___________?

Answer

Correct Answer: Perceived benefits, perceived price

Note: This Question is unanswered, help us to find answer for this one

65. Usually, when you create nested loops, each loop has its own ____.

Answer

Correct Answer: Entrance condition

Note: This Question is unanswered, help us to find answer for this one

66. Using the __________ cipher you choose some number by which to shift each letter of a text.

Answer

Correct Answer: Multi-alphabet substitution

Note: This Question is unanswered, help us to find answer for this one

67. To use the strlen function in a program, you must also write #include ________.

Answer

Correct Answer:

Note: This Question is unanswered, help us to find answer for this one

68. To use stream manipulators, you should include the ________ header file.

Answer

Correct Answer: Iomanip.

Note: This Question is unanswered, help us to find answer for this one

69. To use files in a c++ program you must include the ________ header file.

Answer

Correct Answer: Fstream

Note: This Question is unanswered, help us to find answer for this one

70. To create a macro, you can enter a series of commands in the _____ programming language.

Answer

Correct Answer: VBA

Note: This Question is unanswered, help us to find answer for this one

71. To compare struct variables, you compare them ____.

Answer

Correct Answer: Member-wise

Note: This Question is unanswered, help us to find answer for this one

72. This code is an example of a(n) ____ while loop.

Answer

Correct Answer: EOF-controlled

Note: This Question is unanswered, help us to find answer for this one

73. The word “memory” consists of 48 bits, which is equivalent to _____ bytes.

Answer

Correct Answer: 6

Note: This Question is unanswered, help us to find answer for this one

74. The symbol used to represent a loop condition on a flowchart is the ____ symbol.

Answer

Correct Answer: Diamond

Note: This Question is unanswered, help us to find answer for this one

75. The standard header file for the abs(x)function is ____.

Answer

Correct Answer:

Note: This Question is unanswered, help us to find answer for this one

76. The purpose of the __________ is to get the first input value for the validation of a loop.

Answer

Correct Answer: Priming read

Note: This Question is unanswered, help us to find answer for this one

77. The pointer is indicating the _____.

Answer

Correct Answer: Viral protein coat

Note: This Question is unanswered, help us to find answer for this one

78. The pl/sql block starts with the ____ clause.

Answer

Correct Answer: BEGIN

Note: This Question is unanswered, help us to find answer for this one

79. The __________ function will return the number of characters in a given string.

Answer

Correct Answer: Length_Of()

Note: This Question is unanswered, help us to find answer for this one

80. Members of a(n) ________ union have names, but the union itself has no name.

Answer

Correct Answer: Anonymous

Note: This Question is unanswered, help us to find answer for this one

81. A ____ loop is best used when the specific number of iterations required is known.

Answer

Correct Answer: For-loops

Note: This Question is unanswered, help us to find answer for this one

82. ________ can be used as pointers.

Answer

Correct Answer: Indirectly

Note: This Question is unanswered, help us to find answer for this one

83.

Choose the correct output of the given program.

#include

main()

{

struct b

{

int on:1;

};

struct b v = [1];

printf("%d\n", v.on);


}


Answer

Correct Answer:

0


Note: This Question is unanswered, help us to find answer for this one

84.

What would be the output of the given program?

int main()

{

int i =1, j=1;

for ( ; ; )

{

if ( i > 5 )

break;

else

j += i--;

Printf ( "%d\n", j );

i += j;

j= j+7;

}

return 0;

}


Answer

Correct Answer:

1

 6



Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: The program may crash if some important data gets overwritten.

Note: This Question is unanswered, help us to find answer for this one

86. What is the output of the following code? void myFunction(int foo[2][3]) { foo[0][1] = 5; int i = 0, j = 0; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf("%d ", foo[i][j]); } int main() { int foo[2][3] = {0}; myFunction(foo); return 0; }

Answer

Correct Answer: 0 5 0 0 0 0

Note: This Question is unanswered, help us to find answer for this one

87.

Which of the following is used for dynamically allocating memory?

Answer

Correct Answer: malloc() and calloc()

Note: This Question is unanswered, help us to find answer for this one

88.

Assuming, integer is 2 byte, What will be the output of the program? #include<stdio.h>int main() { printf("%x\n", -2<<2); return 0; }

Answer

Correct Answer: fff8

Note: This Question is unanswered, help us to find answer for this one

89.

#pragma exit is primarily used for?

Answer

Correct Answer: Running a function at exiting the program.

Note: This Question is unanswered, help us to find answer for this one

90.

Many features of C were derived from an earlier language called _____.

Answer

Correct Answer: B

Note: This Question is unanswered, help us to find answer for this one

91.

#include are ___ files and #include “somefile.h” ____ files.

Answer

Correct Answer: They can include all types of file

Note: This Question is unanswered, help us to find answer for this one

92.

Which of the following is an invalid identifier?

Answer

Correct Answer: 1foobar

Note: This Question is unanswered, help us to find answer for this one

93.

#include <stdio.h>int main() { char *var = "Programming in C is fun."; } Which of the following format identifier can never be used for the variable var?

Answer

Correct Answer: %c

Note: This Question is unanswered, help us to find answer for this one

94.

Which of the following is not a Standard Predefined Macro?

Answer

Correct Answer: __BREAK__

Note: This Question is unanswered, help us to find answer for this one

95.

Which statement will you add in following program to work it correctly? #include<stdio.h>int main() { printf("%f\n",log(360.0)); return 0; }

Answer

Correct Answer: #include<math.h>

Note: This Question is unanswered, help us to find answer for this one

96.

Considering that integer is 4 bytes long, what is the output of the following code? int main() { intfoobar=20, *foo, *bar; foo=&foobar; /* Assume address of foobar is 2100*/ bar=foo; *foo++=*bar++; foobar++; printf("foobar=%d, foo=%d, bar=%d\n", foobar, foo, bar); return 0; }

Answer

Correct Answer: foobar=21, foo=2104, bar=2104

Note: This Question is unanswered, help us to find answer for this one

97.

Considering the following definition of a Union MyUnion, if int occupies 4 bytes, what is the memory size occupied by a variable of type MyUnion? union MyUnion { int foo; float bar; char foobar[16]; };

Answer

Correct Answer: 16

Note: This Question is unanswered, help us to find answer for this one

98.

If the storage size of unsigned int is 2 bytes, then the range of values of an unsigned integer is:

Answer

Correct Answer: 0 to 65,535

Note: This Question is unanswered, help us to find answer for this one

99.

Assuming integer is 4 bytes long and the address for 'i' is 2000, what is the output for the following code? int main() { int ***foo, **bar, *foobar, i=5; foobar = &i; bar = &foobar; foo = &bar; printf("%d, %d, %d\n", *foobar, **bar, ***foo); return 0; }

Answer

Correct Answer: 5, 5, 5

Note: This Question is unanswered, help us to find answer for this one

100.

Assuming integer takes 4 bytes and the starting address of the array 'foo' is 2000, what will be the output of the following code? int main() { int foo[2][3][4][5]; foo[2][3][4][5] = 50; printf("%d",*(*(*(*(foo+2)+3)+4)+5)); return 0; }

Answer

Correct Answer: 50

Note: This Question is unanswered, help us to find answer for this one

101.

If short takes 2 bytes of memory, what will be the output of the following program?

 int main () {

short foobar[2][3] = { {1,5}, {9,8,7}}; printf("%d", sizeof(foobar)); return 0; }

Answer

Correct Answer: 12

Note: This Question is unanswered, help us to find answer for this one

102.

Which of the following statements are correct? Check all that apply.

Answer

Correct Answer: The stdio.h header defines variable types, macros, and functions for performing input and output.
The signal.h header defines a variable type, macros and functions to handle different signals reported during a program's execution.
The stdlib.h header defines variable types, macros, and functions for performing general functions.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

103.

Bitwise operators can be used to generate random numbers.

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

104.

In order to fetch the address of a variable, we write preceding _____ sign before variable name.

Answer

Correct Answer: Ampersand

Note: This Question is unanswered, help us to find answer for this one

105.

Which keyword is used to declare a variable so that the variable can be accessed by all the functions in all the modules of a program?

Answer

Correct Answer: extern

Note: This Question is unanswered, help us to find answer for this one

106.

Which function is called at program startup?

Answer

Correct Answer: main()

Note: This Question is unanswered, help us to find answer for this one

107.

Which of the following declaration is not supported by C?

Answer

Correct Answer: String str;

Note: This Question is unanswered, help us to find answer for this one

108.

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

Answer

Correct Answer: ptr is a pointer to an array of 10 integers

Note: This Question is unanswered, help us to find answer for this one

109.

Which of the following is not a logical operator?

Answer

Correct Answer: &

Note: This Question is unanswered, help us to find answer for this one

110.

What does argc and argv indicate in command-line arguments? (Assuming: int main(int argc, char *argv[]) )

Answer

Correct Answer: argument count, argument vector

Note: This Question is unanswered, help us to find answer for this one

111.

The keyword ‘break’ cannot be simply used within __?

Answer

Correct Answer: If-else

Note: This Question is unanswered, help us to find answer for this one

112.

How will you free the allocated memory?

Answer

Correct Answer: free(var-name)

Note: This Question is unanswered, help us to find answer for this one

113.

How will you print \n on the screen?

Answer

Correct Answer: printf("\\n")

Note: This Question is unanswered, help us to find answer for this one

114.

What is the built in library function to adjust the allocated dynamic memory size?

Answer

Correct Answer: realloc

Note: This Question is unanswered, help us to find answer for this one

115.

Offset used in fseek() function call can be a negative number.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

116.

Offset used in fseek() function call can be a negative number.

Answer

Correct Answer: foo = fopen ("bar.txt", "a");

Note: This Question is unanswered, help us to find answer for this one

117.

Which of the following correctly shows the hierarchy of arithmetic operators in C?

Answer

Correct Answer: / * + -

Note: This Question is unanswered, help us to find answer for this one

118.

Which of the following operations can be performed on the file "NOTES.TXT" using the below code? FILE *fp; fp = fopen("NOTES.TXT", "r+");

Answer

Correct Answer: Read and Write

Note: This Question is unanswered, help us to find answer for this one

119.

Which storage class is the default storage class for all local variables?

Answer

Correct Answer: auto

Note: This Question is unanswered, help us to find answer for this one

120.

Which keyword is used to retain value of a variable in multiple function invocations?

Answer

Correct Answer: static

Note: This Question is unanswered, help us to find answer for this one

121.

An array elements are always stored in ____ memory locations.

Answer

Correct Answer: Address

Note: This Question is unanswered, help us to find answer for this one

122.

An array elements are always stored in ____ memory locations.

Answer

Correct Answer: Sequential

Note: This Question is unanswered, help us to find answer for this one

123.

An array elements are always stored in ____ memory locations.

Answer

Correct Answer: The address of the first element of the array

Note: This Question is unanswered, help us to find answer for this one

124.

A file written in text mode can be read back in binary mode.

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

125.

Smallest element of an array is called as __.

Answer

Correct Answer: Lower Bound

Note: This Question is unanswered, help us to find answer for this one

126.

What is the output of the following program? main( ) { int foo = ('k' - 'j')/4; printf("foo = %d",foo); return 0; }

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

127.

For binary files, a ___ must be appended to the mode string.

Answer

Correct Answer: “b”

Note: This Question is unanswered, help us to find answer for this one

128.

What type of array is generally generated in Command-line argument?

Answer

Correct Answer: Jagged Array

Note: This Question is unanswered, help us to find answer for this one

129.

Declare the following statement? "An array of three pointers to chars"

Answer

Correct Answer: char *ptr[3];

Note: This Question is unanswered, help us to find answer for this one

130.

Left shifting a number by 1 is always equivalent to multiplying it by 2.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

131.

Which function is used to check if the end of the file has been reached in C?

Answer

Correct Answer: feof()

Note: This Question is unanswered, help us to find answer for this one

132.

The maximum combined length of the command-line arguments including the spaces between adjacent arguments is

Answer

Correct Answer: It may vary from one operating system to another

Note: This Question is unanswered, help us to find answer for this one

133.

What will be the output of the program ? #include<stdio.h> int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; }

Answer

Correct Answer: 3, 2, 15

Note: This Question is unanswered, help us to find answer for this one

134.

Which header file should be included to use functions like malloc() and calloc()?

Answer

Correct Answer: stdlib.h

Note: This Question is unanswered, help us to find answer for this one

135.

Where is the file searched, when #include is used with angular brackets <>?

Answer

Correct Answer: System Libraries

Note: This Question is unanswered, help us to find answer for this one

136.

Which of the following is not a Preprocessor Directive in C?

Answer

Correct Answer: #elseif

Note: This Question is unanswered, help us to find answer for this one

137.

#include <stdio.h> is a __?

 

Answer

Correct Answer: Preprocessor directive

Note: This Question is unanswered, help us to find answer for this one

138.

Which of the following are C preprocessors?

 

Answer

Correct Answer: All of the mentioned.

Note: This Question is unanswered, help us to find answer for this one

139.

C preprocessors can have compiler specific features.

 

Answer

Correct Answer: true

Note: This Question is unanswered, help us to find answer for this one

140.

Consider the 32 bit compiler. We need to store address of integer variable to integer pointer. What will be the size of integer pointer ?

 

Answer

Correct Answer: 2 Bytes

Note: This Question is unanswered, help us to find answer for this one

141.

What is (void*)0?

 

Answer

Correct Answer: Representation of NULL pointer

Note: This Question is unanswered, help us to find answer for this one

142.

What is the output of the following program? int main () { int foo = 1; do{ printf("%d ", foo); foo++; }while( foo <= 10 ) return 0; }

 

Answer

Correct Answer: The program will not execute due to an error

Note: This Question is unanswered, help us to find answer for this one

143.

What is used to convert a C program into machine language for execution?

 

Answer

Correct Answer: Assembler

Note: This Question is unanswered, help us to find answer for this one

144.

Pick the incorrect fopen statement:

 

Answer

Correct Answer: None of the above

Note: This Question is unanswered, help us to find answer for this one

145.

What is the output of the following code snippet? #include<stdio.h> main() { int x = 5; if(x=5) { if(x=5) break; printf("Hello"); } printf("Hi"); }

 

Answer

Correct Answer: Compile error

Note: This Question is unanswered, help us to find answer for this one

146.

Which function is used to de-allocate the memory allocated using malloc()?

 

Answer

Correct Answer: free()

Note: This Question is unanswered, help us to find answer for this one

147.

What will be the output of following code? int main() { int a=5; if(a=10) printf("Value of a=%d",a); else printf("Value of a=%d",a); return 0; }

 

Answer

Correct Answer:

Value of a=10



Note: This Question is unanswered, help us to find answer for this one

148.

Which of the following is an invalid operator?

 

Answer

Correct Answer: <>

Note: This Question is unanswered, help us to find answer for this one

149.

What will be the output of following program? #include<stdio.h> int main() { int y=128; const int x=y; printf("%d\n",x); return 0; }

 

Answer

Correct Answer: 128

Note: This Question is unanswered, help us to find answer for this one

150.

What is the output of the following code? main() { int foo = 10; foo = foo << 2; printf("foo = %d",foo); }

 

Answer

Correct Answer: foo = 40

Note: This Question is unanswered, help us to find answer for this one

151.

Which of the following is the correct usage of conditional operator in C?

 

Answer

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

Note: This Question is unanswered, help us to find answer for this one

152.

What is the output of this C code? #include <stdio.h> void main() { int x = 1, y = 0, z = 5; int a = x && y || z++; printf("%d", z); }




 

Answer

Correct Answer: 6

Note: This Question is unanswered, help us to find answer for this one

153.

Which bit wise operator is suitable for turning off a particular bit in a number?

 

Answer

Correct Answer: & operator

Note: This Question is unanswered, help us to find answer for this one

154.

Bit wise & and | are unary operators.

 

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

155.

Which format specifier can be used to print a float value?

 

Answer

Correct Answer: %f

Note: This Question is unanswered, help us to find answer for this one

156.

Which format specifier can be used to print a float value?

 

Answer

Correct Answer: 1, 2, 3

Note: This Question is unanswered, help us to find answer for this one

157.

What will be the output of following program? #include<stdio.h> int main() { int k=1; printf("%d==1 is " "%s\n",k,k==1?"TRUE":"FALSE"); return 0; }


 

Answer

Correct Answer: 1==1 is TRUE

Note: This Question is unanswered, help us to find answer for this one

158.

In the following code, the p2 is Integer pointer or Integer? typedef int *ptr; ptr p1,p2;

 

Answer

Correct Answer: Integer Pointer

Note: This Question is unanswered, help us to find answer for this one

159.

Which of the following cannot be a variable name in C?

 

Answer

Correct Answer: Volatile

Note: This Question is unanswered, help us to find answer for this one

160.

If there is any error while opening a file, fopen will return?

 

Answer

Correct Answer: NULL

Note: This Question is unanswered, help us to find answer for this one

161.

What is the following program doing? #include<stdio.h> main() { FILE *stream=fopen("a.txt",'r'); }


 

Answer

Correct Answer: Compile error

Note: This Question is unanswered, help us to find answer for this one

162.

Can you combine the following two statements into one? char *p; p = (char*) malloc(100);

 

Answer

Correct Answer: char *p = (char*)malloc(100);

Note: This Question is unanswered, help us to find answer for this one

163.

What will be the output of following program? #include<stdio.h> int main() { const int x=5; const int *ptrx; ptrx=&x; *ptrx=10; printf("%d\n",x); return 0; }


 

Answer

Correct Answer: Error

Note: This Question is unanswered, help us to find answer for this one

164.

Let x be an array. Which of the following operations are illegal? a) ++x b) x+1 c) x++ d) x*2

 

Answer

Correct Answer: a, c and d

Note: This Question is unanswered, help us to find answer for this one

165.

What will be the output of following code? main() { int foo = 20; int bar = 3; float foobar; foobar = (float) foo / bar; foo = foobar; printf("foobar = %5.3f\nfoo = %d", foobar, foo ); }

 

Answer

Correct Answer: foobar = 6.667 foo = 6

Note: This Question is unanswered, help us to find answer for this one

166.

All keywords in C are in _____.

 

Answer

Correct Answer: LowerCase letters

Note: This Question is unanswered, help us to find answer for this one

167.

What does fp point to in the program ? #include<stdio.h> int main() { FILE *fp; fp=fopen("trial", "r"); return 0; }

 

Answer

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

Note: This Question is unanswered, help us to find answer for this one

168.

Which of the following syntax is correct for command-line arguments?

 

Answer

Correct Answer: int main(int var, char *varg[])

Note: This Question is unanswered, help us to find answer for this one

169.

The preprocessor provides the ability for ___.

 

Answer

Correct Answer: All of the mentioned.

Note: This Question is unanswered, help us to find answer for this one

170.

Which type of files can’t be opened using fopen()?

 

Answer

Correct Answer: None of the mentioned

Note: This Question is unanswered, help us to find answer for this one

171.

What does the following declaration signify? char *arr[10];

 

Answer

Correct Answer: arr is an array of 10 character pointers

Note: This Question is unanswered, help us to find answer for this one

172.

Which of the following operators is used to access the data members of a structure?

 

Answer

Correct Answer: .

Note: This Question is unanswered, help us to find answer for this one

173.

Point out the error in the following code: struct emp { int ecode; struct emp *e; }

 

Answer

Correct Answer: Error in structure declaration

Note: This Question is unanswered, help us to find answer for this one

174.

Which operator connects the structure name to its member name?

 

Answer

Correct Answer: . (dot)

Note: This Question is unanswered, help us to find answer for this one

175.

The prototype of a function can be used to :

 

Answer

Correct Answer: Declare a function

Note: This Question is unanswered, help us to find answer for this one

176.

Which keyword is used to transfer control from a function back to the calling function?

 

Answer

Correct Answer: return

Note: This Question is unanswered, help us to find answer for this one

177.

Which operation is illegal in structures?

 

Answer

Correct Answer: Typecasting of structure

Note: This Question is unanswered, help us to find answer for this one

178.

Point out the error in the following program(if it is compiled with Turbo C compiler)? #include<stdio.h> int main() { display(); return 0; } void display() { printf("Upwork.com"); }

 

Answer

Correct Answer: display() is called before it is defined

Note: This Question is unanswered, help us to find answer for this one

179.

Which of the following can not be a member in a structure?

 

Answer

Correct Answer: A function

Note: This Question is unanswered, help us to find answer for this one

180.

What is the scope of a function?

 

Answer

Correct Answer: From the point of declaration to the end of the file being compiled.

Note: This Question is unanswered, help us to find answer for this one

181.

In which stage the following code : #include<stdio.h> gets replaced by the contents of the file stdio.h?

 

Answer

Correct Answer: During preprocessing

Note: This Question is unanswered, help us to find answer for this one

182.

Which of the following functions can be used to set the file position indicator to the beginning of the file?

 

Answer

Correct Answer: fseek()
rewind()

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

183.

Point out the error in the program? typedef struct data mystruct; struct data { int x; mystruct *b; };

 

Answer

Correct Answer: No Error

Note: This Question is unanswered, help us to find answer for this one

184.

True or False: "The expressions *ptr++ and ++*ptr are same"

 

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

185.

Which of the following is a correct way to initialize an array?

 

Answer

Correct Answer: int n[6] = { 2, 4, 12, 5, 45, 5 };

Note: This Question is unanswered, help us to find answer for this one

186.

Which of the following is not a valid variable declaration?

 

Answer

Correct Answer: int 3_a;

Note: This Question is unanswered, help us to find answer for this one

187.

Which of the following is a correct format for declaration of a function?

 

Answer

Correct Answer: return-type function-name(argument type);

Note: This Question is unanswered, help us to find answer for this one

188.

When a program uses command line arguments, then argv[0]?

 

Answer

Correct Answer: holds the name of the program itself.

Note: This Question is unanswered, help us to find answer for this one

189.

Which of the following is TRUE about argv?

 

Answer

Correct Answer: It is an array of character pointers

Note: This Question is unanswered, help us to find answer for this one

190.

What is argc used for?

 

Answer

Correct Answer: It is the number of arguments passed to the program

Note: This Question is unanswered, help us to find answer for this one

191.

How many times "Upwork" gets printed? #include<stdio.h> int main() { int x; for(x=-1;x<=10;x++) { if(x<5) continue; else break; printf("Upwork"); } return 0; }

 

Answer

Correct Answer: 0 times

Note: This Question is unanswered, help us to find answer for this one

192.

What is the output of this C code? int main() { int i = 10; void *p = &i; printf("%d\n", (int)*p); return 0; }

 

Answer

Correct Answer: Compile time error

Note: This Question is unanswered, help us to find answer for this one

193.

log(x) function defined in math.h header file is

 

Answer

Correct Answer: Natural base logarithm.

Note: This Question is unanswered, help us to find answer for this one

194.

What is the output of the following code? int main() { FILE *foobar = stdout; int foo; fprintf(foobar, "%d ", 20); fflush(stdout); fprintf(stderr, "%d", 99); return 0; }

 

Answer

Correct Answer: 20 99

Note: This Question is unanswered, help us to find answer for this one

195.

What will be the output of following code:- #include<stdio.h> #include<stdarg.h> void display(int num,...); int main() { display(4,'A','B','C','D'); return 0; } void display(int num, ...) { char c,c1; int j; va_list ptr,ptr1; va_start(ptr,num); va_start(ptr1,num); for(j=1;j<=num;j++) { c=va_arg(ptr, int); printf("%c,",c); c1=va_arg(ptr1, int); printf("%d\n",c1); } }

 

Answer

Correct Answer: A,65 B,66 C,67 D,68

Note: This Question is unanswered, help us to find answer for this one

196.

How many times i value is checked in the below code? #include <stdio.h> int main() { int i = 0; do { i++; printf("in while loop\n"); } while (i < 3); }

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

197.

If the two strings are identical, the strcmp() function returns?

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

198.

The first argument in command line arguments is?

Answer

Correct Answer: The number of command-line arguments the program was invoked with.

Note: This Question is unanswered, help us to find answer for this one

199.

How many times the program will print "Hello World" ? #include<stdio.h> int main() { printf("Hello World"); main(); return 0; }

Answer

Correct Answer: Till stack overflows

Note: This Question is unanswered, help us to find answer for this one

200.

What will be the output of following code?

int' main()

 {

         int i;

         i = 0;

   for (i = 1; i <2; i++)

{

           i++;

         printf( "%d", i );

        continue;

        printf( "%d", i );

 }

 return 0;

}

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

201.

What would be printed on the standard output as a result of the following code snippet? #include<stdio.h> main() { unsigned char a=255; a = a+1; printf("%d",a); return 0; }

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

202.

What would be printed on the standard output as a result of the following code snippet? main() { int arr[10]; int a = sizeof(arr); printf("%d\n",a); return 0; }

Answer

Correct Answer: 40

Note: This Question is unanswered, help us to find answer for this one

203.

Which standard function is used to clear memory allocated by the malloc() function?

Answer

Correct Answer: free

Note: This Question is unanswered, help us to find answer for this one

204.

What is the output of the following program ? main() { int u = 1, v = 3; printf("%d %d",u,v); funct1(&u,&v); printf(" %d %d\n",u,v); } void funct1(int *pu, int *pv) { *pu=0; *pv=0; return; }

Answer

Correct Answer: 1 3 0 0

Note: This Question is unanswered, help us to find answer for this one

205.

In which area of memory are static variables allocated?

Answer

Correct Answer: stack

Note: This Question is unanswered, help us to find answer for this one

206.

What would be printed on the standard output as a result of the
following code snippet?
 
main()
{
enum {red, green, blue = 0, white};
printf("%d %d %d %d", red, green, blue, white);
return 0;
}

Answer

Correct Answer: 0 1 0 1

Note: This Question is unanswered, help us to find answer for this one

207.

Which of the following is not a valid mode for opening a file?

Answer

Correct Answer: i

Note: This Question is unanswered, help us to find answer for this one

208.

Which of the following is not a string function?

Answer

Correct Answer: strcomp()

Note: This Question is unanswered, help us to find answer for this one

209.

What will be printed on the standard output as a result of the following
code snippet?
void func()
{
static int i = 1;
int j = 1;
i++;
j++;
printf("%d %d ",i,j);
}
void main()
{
func();
func();
func();
}

Answer

Correct Answer: 2 2 3 2 4 2

Note: This Question is unanswered, help us to find answer for this one

210.

What will be printed on the standard output as a result of the following
code snippet?
void main()
{
int arr[][2] = {1,2,3,4,5,6};
printf("%d",arr[2][1]);
}

Answer

Correct Answer: 6

Note: This Question is unanswered, help us to find answer for this one

211.

Which of the following is not a type of operator ?

Answer

Correct Answer: Rational

Note: This Question is unanswered, help us to find answer for this one

212.

From which of the following loop or conditional constructs, is "break"
used for an early exit?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

213.

Which of the following comparison statements will be true if an
integer is 16 bits and a long is 32 bits on a machine?

Answer

Correct Answer: -1L < 1U
-1L > 1UL

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

214.

What would be printed on the standard output as a result of the
following code snippet?
main()
{
signed char i = 1;
for (; i<=255; i++)
printf ("%d ",i);
return 0;
}

Answer

Correct Answer: 1 2 3 . . . 127 -128 -127 ... 0 1 2 3 . . . (infinite times)

Note: This Question is unanswered, help us to find answer for this one

215.

An array is defined with the following statement in a file, file1.c
int a[ ] = { 1, 2, 3, 4, 5, 6 };
In another file, file2.c, the following code snippet is written to use the
array a:
extern int a[];
int size = sizeof(a);
What is wrong with the above code snippet?

Answer

Correct Answer: An extern array of unspecified size is an incomplete type. The size of the operator during compile time is unable to learn the size of an array that is defined in another file

Note: This Question is unanswered, help us to find answer for this one

216.

Which of the following is the correct way of initializing a twodimensional array?

Answer

Correct Answer: a, b and c

Note: This Question is unanswered, help us to find answer for this one

217.

Which of the following standard functions is used to close a file?

Answer

Correct Answer: fclose()

Note: This Question is unanswered, help us to find answer for this one

218.

Study the following code:
int n = 2;
int a[n];
What is the error in the above code?

Answer

Correct Answer: A constant value has to be given in place of a variable for array declaration

Note: This Question is unanswered, help us to find answer for this one

219.

What will happen when the following code is executed?

{
int num;
num =0;
do {-- num;
printf("%d\n", num);
num++;
} while (num >=0);
}

Answer

Correct Answer: There will be a compilation error

Note: This Question is unanswered, help us to find answer for this one

220.

What would be printed on the standard output as a result of the
following code snippet?
main()
{
int i=5;
char option = 5;
switch(option)

{
case '5':
printf("case : 1 \n");
break;
case i:
printf("case : 2 \n");
break;
default:
printf("case : 3 \n");
break;
}
return 0;
}

Answer

Correct Answer: Result in compilation error

Note: This Question is unanswered, help us to find answer for this one

221.

What would be printed on the standard output as a result of the
following code snippet?
 
#define max(a, b)((a) > (b)?(a):(b))
main()
{
int a=4, c = 5;
printf("%d ", max(a++, c++));
printf("%d %d\n", a,c);
}

Answer

Correct Answer: 6 5 7

Note: This Question is unanswered, help us to find answer for this one

222.

What would be printed on the standard output as a result of the
following code snippet?
#define func(t, a, b) { t temp; temp=a; a=b; b=temp; }
main()
{
int a=3, b=4;
float c=4.5, d = 5.99;
func(int, a, b);
func(float, c, d);
printf("%d %d ", a, b);
printf("%.2f %.2f\n", c, d);
}

Answer

Correct Answer: 4 3 5.99 4.50

Note: This Question is unanswered, help us to find answer for this one

223.

What would be printed on the standard output as a result of the
following code snippet?
main()
{
int a[5] = {1,4,5,6,9};
printf("%d\t", *a); //Line 1
printf("%d", *++a); //Line 2
return 0;
}

Answer

Correct Answer: Compilation Error in "Line 2"

Note: This Question is unanswered, help us to find answer for this one

224.

If a two dimensional array arr[4][10](an array with 4 rows and 10 columns) is to be passed in a function, which of the following would be the valid parameters in the function definition?

Answer

Correct Answer: fn(int arr[4][10])
fn(int arr[][10])
fn(int (*fn)[13])

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

225.

Given the array:
 
int num[3][4]=
{
{3,6,9,12},
{15,25,30,35},
{66,77,88,99}
};
what would be the output of *(*(num+1))?

Answer

Correct Answer: 15

Note: This Question is unanswered, help us to find answer for this one

226.

What will be printed on the standard output as a result of the following
code snippet?
void main()
{
int arr[5]={1,2,3,4,5};
printf("%d\n", *(arr+4));
}

Answer

Correct Answer: 5

Note: This Question is unanswered, help us to find answer for this one

227.

Is the following statement correct? If not, why not? If yes, what is the
size of the array?
int array[][3] = { {1,2}, {2,3}, {3,4,2} };

Answer

Correct Answer: Yes, the size is three columns by three rows

Note: This Question is unanswered, help us to find answer for this one

228.

What would be printed on the standard output as a result of the
following code snippet?
main()
{
 
char *s="Hello World";
char s1[20], s2[20];
int len = sscanf(s,"%s",s1);
printf("%s : %d", s1, len);
}


 

Answer

Correct Answer: Hello : 1

Note: This Question is unanswered, help us to find answer for this one

229.

Which of the following functions is used to extract formatted input
from a file?

Answer

Correct Answer: fscanf()

Note: This Question is unanswered, help us to find answer for this one

230.

What does the following function do?
int fn(unsigned int x)
{
int count = 0;
for(; x!=0; x&=(x-1))
count++;
return count;
}

Answer

Correct Answer: Returns the minimum number of bits required to represent the number x

Note: This Question is unanswered, help us to find answer for this one

231.

What will be the output of the following program?
#include <assert.h>
main()
{
int n = 5;
assert(n > 3); //statement 1
n = n+2;
assert(n > 7);//statement 2
return 0;
}

Answer

Correct Answer: Assertion 'n > 7' failed; Program aborts at statement 2

Note: This Question is unanswered, help us to find answer for this one

232.

What is the error in the following statement where str is a character
array and the statement is supposed to traverse through the whole
character string str?
for(i=0;str[i];i++)

Answer

Correct Answer: The condition should be str[i] != '\0'

Note: This Question is unanswered, help us to find answer for this one

233.

In order to read structures/records from a file, which function will you
use?

Answer

Correct Answer: fread()

Note: This Question is unanswered, help us to find answer for this one

234.

What would be printed on the standard output as a result of the
following code snippet?
int b = 5;
main()
{
void addup (int b);
int i;
for(i=1; i<=5; i++)
addup(1);
return 0;
}
void addup (int b)
{
static int v1;
v1 = v1+b;
printf("%d ", v1);
}

Answer

Correct Answer: 1 2 3 4 5

Note: This Question is unanswered, help us to find answer for this one

235.

Which of the following declarations of structures is/are valid?
1)
struct node {
int count;
char *word;
struct node next;
}Node;
 
2)
struct node {
int count;
char *word;
struct node *next;
}Node;
3)
struct node {
int count;
char *word;
union u1 {
int n1;
float f1;
}U;
}Node;

Answer

Correct Answer: 23

Note: This Question is unanswered, help us to find answer for this one

236.

Which file header is to be included for file handling in a C program?

Answer

Correct Answer: stdio.h

Note: This Question is unanswered, help us to find answer for this one

237.

Given the following array:
char books[][40]={
"The Little World of Don Camillo",
"To Kill a Mockingbird",
"My Family and Other Animals",
"Birds, Beasts and Relatives"
};
what would be the output of printf("%c",books[2][5]);?

Answer

Correct Answer: m

Note: This Question is unanswered, help us to find answer for this one

238.

What would be printed on the standard output as a result of the
following code snippet?
char i = 'A';
char *j;
j = & i;
 
*j = *j + 32;
printf("%c",i);

Answer

Correct Answer: a

Note: This Question is unanswered, help us to find answer for this one

239.

Identify the incorrect statement.

Answer

Correct Answer: Memory is reserved when a structure label is defined

Note: This Question is unanswered, help us to find answer for this one

240.

What would be printed on the standard output as a result of the
following code snippet?
char *str1 = "Hello World";
strcat(str1, '!');
printf("%s", str1);

Answer

Correct Answer: The code snippet will throw a compilation error

Note: This Question is unanswered, help us to find answer for this one

241.

What is the return value in case a file is not opened successfully by
using fopen()?

Answer

Correct Answer: NULL

Note: This Question is unanswered, help us to find answer for this one

242.

Which of the following statements is/are valid and correct?
1.char amessage[] = "lmnop";
amessage++;
2.char *pmessage = "abcde";
(*pmessage)++;
3.char amessage[] = "lmnop";
(*amessage)++;
4.char *pmessage = "abcde";
pmessage++;

Answer

Correct Answer: 34

Note: This Question is unanswered, help us to find answer for this one

243.

The declaration int (*p[5])() means:

Answer

Correct Answer: p is an array of pointers to functions the return type of which is an integer

Note: This Question is unanswered, help us to find answer for this one

244.

What is wrong with the following statement?
int func();

Answer

Correct Answer: There is nothing wrong with the statement

Note: This Question is unanswered, help us to find answer for this one

245.

Consider the following code.
int i = 4, *j, *k;
Which one of the following statements will not work?

Answer

Correct Answer: j = j * 2;

Note: This Question is unanswered, help us to find answer for this one

246.

Given the following array:
int a[8] = {1,2,3,4,5,6,7,0};
what would be the output of
printf("%d",a[4]); ?

Answer

Correct Answer: 5

Note: This Question is unanswered, help us to find answer for this one

247.

What will be printed on the standard output as a result of the following
code snippet?
int funr(int x, int y)
{
if(x <= 0)
{
return y;
}
else
{
return (1+funr(x-1,y));
}
}
void main()
{
printf("%d",funr(2,3));
}

Answer

Correct Answer: 5

Note: This Question is unanswered, help us to find answer for this one

248.

Given the array:
int num[3][4]= {
{3,6,9,12},
{15,25,30,35},
{66,77,88,99}
};
what would be the output of *(*(num+1)+1)+1?

Answer

Correct Answer: 26

Note: This Question is unanswered, help us to find answer for this one

249.

Which function will you use to write a formatted output to the file?

Answer

Correct Answer: fprintf()

Note: This Question is unanswered, help us to find answer for this one

250.

Which of the following is not a file related function?

Answer

Correct Answer: puts()

Note: This Question is unanswered, help us to find answer for this one

251.

What would be printed on the standard output as a result of the
following code snippet?
void main()
{
unsigned char a=25;
 
a = ~a;
signed char b = 25;
b = ~b;
printf("%d %d ", a, b);
}

Answer

Correct Answer: 230 -26

Note: This Question is unanswered, help us to find answer for this one

252.

What will happen if you assign a value to an element of an array the
subscript of which exceeds the size of the array?

Answer

Correct Answer: You will get an error message from the compiler

Note: This Question is unanswered, help us to find answer for this one

253.

Given the operators:
1) *
2) /
3) %
What would be the order of precedence?

Answer

Correct Answer: All have the same precedence

Note: This Question is unanswered, help us to find answer for this one

254.

What would be printed on the standard output as a result of the
following code snippet?
#define max(a, b) ((a) > (b)?(a):(b))
main()
 
{
int a=4;
float b=4.5;
printf("%.2f\n",max(a, b));
}

Answer

Correct Answer: 4.50

Note: This Question is unanswered, help us to find answer for this one

255.

What is the function to concatenate two strings?

Answer

Correct Answer: strcat()

Note: This Question is unanswered, help us to find answer for this one

256.

Which is/are the type/s of memory allocation that needs/need the
programmer to take care of memory management?

Answer

Correct Answer: Dynamic memory allocation
Memory allocation on stack

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

257.

Which of the following statements will result in a compilation error?

Answer

Correct Answer: int n=5, x; x= ++n++;
int n=5, x; x= (n+1)++;
int n=5, x=6; x= (n+x)++;

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

258.

Which of the following is/are the correct signature/s of main with
command line arguments?

Answer

Correct Answer: int main(int argc, char **argv)
int main(int argc, char *argv[])

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

259.

What would be printed on the standard output as a result of the
following code snippet?
#define Name Manish
main()
{
printf("My name""Name");
}

Answer

Correct Answer: My nameName

Note: This Question is unanswered, help us to find answer for this one

260.

By which file function you can position the file pointer in accordance
with the current position?

Answer

Correct Answer: fseek()

Note: This Question is unanswered, help us to find answer for this one

261.

Which function will convert a string into a double precision quantity?

Answer

Correct Answer: atof()

Note: This Question is unanswered, help us to find answer for this one

262.

What will be printed on the standard output as a result of the following
code snippet?
void main()
{
char arr1[] = "REGALINT";
printf("%d,",strlen(arr1));
printf("%d",sizeof(arr1));
}

Answer

Correct Answer: 8,9

Note: This Question is unanswered, help us to find answer for this one

263.

What will happen when the following code is executed?
void main()
{
char arr1[] = "REGALINT";
char *arr2;
 
arr2 = arr1;
printf("%d,",sizeof(arr1));
printf("%d",sizeof(arr2));
}

Answer

Correct Answer: 9,4

Note: This Question is unanswered, help us to find answer for this one

264.

Given the following array:
char books[][40]={
"The Little World of Don Camillo",
"To Kill a Mockingbird",
"My Family and Other Animals",
"Birds, Beasts and Relatives"
};
what would be the output of printf("%s",books[3]);?

Answer

Correct Answer: Birds, Beasts and Relatives

Note: This Question is unanswered, help us to find answer for this one

265.

What happens when the continue keyword is encountered in the 'for
loop'?

Answer

Correct Answer: Control passes to the condition of the loop

Note: This Question is unanswered, help us to find answer for this one

266.

What will be printed on the standard output as a result of the following
code snippet?
void main()
{
char arr[] = {'R','A','M','\0'};
 
printf("%d",strlen(arr));
}

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

267.

Select the correct statement about arrays.

Answer

Correct Answer: An array declared as A[100][100] can hold a maximum of 10000 elements

Note: This Question is unanswered, help us to find answer for this one

268.

What would be printed on the standard output as a result of the
following code snippet?
main()
{
char *pmessage = "asdfgh";
*pmessage++;
printf("%s", pmessage);
return 0;
}

Answer

Correct Answer: sdfgh

Note: This Question is unanswered, help us to find answer for this one

269.

What would be printed on the standard output as a result of the
following code snippet?
main()
{
void addup (int b);
addup(b);
return 0;
}
int b = 5;
 
void addup (int b)
{
static int v1;
v1 = v1+b;
printf("%d ", v1);
}

Answer

Correct Answer: Will result in Compilation Error

Note: This Question is unanswered, help us to find answer for this one

270.

The declaration int *(*p)[10] indicates:

Answer

Correct Answer: p is a pointer to an array of integer pointers

Note: This Question is unanswered, help us to find answer for this one

271.

What is the return type of the following function declaration?
func(char c);

Answer

Correct Answer: void

Note: This Question is unanswered, help us to find answer for this one

272.

Read the statement below:
extern int a;
 
Which of the following statement/s pertaining to the above statement
is/are correct?

Answer

Correct Answer: Declares an integer variable a; Does not allocate the storage for the variable

Note: This Question is unanswered, help us to find answer for this one

273.

What would be printed on the standard output as a result of the
following code snippet?
main()
{
enum {red, green, blue = 6, white};
printf("%d %d %d %d", red, green, blue, white);
return 0;
}

Answer

Correct Answer: 0 1 6 7

Note: This Question is unanswered, help us to find answer for this one

274.

What will be the output of the following program, assuming that data
type short takes 2 bytes for storage?
struct node
{
unsigned char bit1 : 1;
unsigned char bit2 : 1;
unsigned short bit3 : 7;
} node1;
main()
{
int size = sizeof(node1);
 
printf("%d", size);
}

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

275.

What would be printed on the standard output as a result of the
following code snippet?
main()
{
int n=5, x;
x = n++;
printf("%d ", x);
x = ++n;
printf("%d ", x++);
printf("%d", x);
 
return 0;
}

Answer

Correct Answer: 5 7 8

Note: This Question is unanswered, help us to find answer for this one

276.

Which of the following is a function for formatting data in memory?

Answer

Correct Answer: sprintf()

Note: This Question is unanswered, help us to find answer for this one

277.

What does the argv[0] represent?

Answer

Correct Answer: The program name

Note: This Question is unanswered, help us to find answer for this one

278.

What will be printed on the standard output as a result of the following
code snippet?
void main()
{
int i,j,k;
i=4;

j=30;
k=0;
k=j++/i++;
++k;
printf("%d %d %d",i,j,k);
}

Answer

Correct Answer: 5 31 8

Note: This Question is unanswered, help us to find answer for this one

279.

Which function will convert a string into an integer?

Answer

Correct Answer: atoi()

Note: This Question is unanswered, help us to find answer for this one

280.

Which function will you use to position the file pointer at the beginning
of the file?

Answer

Correct Answer: a or b

Note: This Question is unanswered, help us to find answer for this one

281.

Which function allocates memory and initializes elements to 0?

Answer

Correct Answer: calloc()

Note: This Question is unanswered, help us to find answer for this one

282.

Which of the following sets of conversion statements may result in the
loss of data?

Answer

Correct Answer: int i; char c; c=i; i=c;
int i; float f; i=f; f=i;

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

283.

Which of the following is not a storage type?

Answer

Correct Answer: global

Note: This Question is unanswered, help us to find answer for this one

284.

Suppose there is a file a.dat which has to be opened in the read
mode using the FILE pointer ptr1, what will be the correct syntax?

Answer

Correct Answer: ptr1 = fopen("a.dat","r");

Note: This Question is unanswered, help us to find answer for this one

285.

Which header file are methods(or macros) isalpha(), islower() a part
of?

Answer

Correct Answer: ctype.h

Note: This Question is unanswered, help us to find answer for this one

286.

Given the following array declaration:
int a[2][3][4]
 
what would be the number of elements in array a?

Answer

Correct Answer: 24

Note: This Question is unanswered, help us to find answer for this one

287.

Study the following code where num is an integer array and n is the
length of the array:
for(i=0;i<n-1;i++)
{
 
for(j=i+1;j<n;j++)
{
if(num[i] > num[j])
{
var=num[i];
num[i]=num[j];
num[j]=var;
}
}
}
What does the above code do?

Answer

Correct Answer: It sorts the array in the ascending order

Note: This Question is unanswered, help us to find answer for this one

288.

Read the following two declaration statements.
1. #include
 
2. #include "stdio.h"
Which of the following statements pertaining to the above two
statements are correct?

Answer

Correct Answer: For statement 1, the header file will be searched in the standard system directories such as "/usr/include"
For statement 2, the header file will be searched first in the local directory and then in the standard system directories such as "/usr/include"

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

289.

What would be printed on the standard output as a result of the
following code snippet?
int Recur(int num)
{
if(num==1 || num==0)


return 1;
if(num%2==0)
return Recur(num/2)+2;
else
return Recur(num-1)+3;
}
int main()
{
int a=9;
printf("%d\n", Recur(a));
return 0;
}

Answer

Correct Answer: 10

Note: This Question is unanswered, help us to find answer for this one

290.

What would be printed on the standard output as a result of the
following code snippet?
main( )
{
char *str[ ] = {
"Manish"
"Kumar"
"Choudhary"
};

printf ( "\nstring1 = %s", str[0] );
printf ( "\nstring2 = %s", str[1] );
printf ( "\nstring3 = %s", str[2] );
}

Answer

Correct Answer: string1 = ManishKumarChoudhary string2 = (null) string3 = (null)

Note: This Question is unanswered, help us to find answer for this one

291.

Which of the following statements are correct for the keyword register?

Answer

Correct Answer: It is a storage-class-specifier

Note: This Question is unanswered, help us to find answer for this one

292.

Which of the following is the correct way of initializing a two-dimensional array?

Answer

Correct Answer: a, b and c

Note: This Question is unanswered, help us to find answer for this one

293. What will be the output of the following program: #include int main(){ int a,b; a= -3 - - 25; b= -5 - (- 29); printf("a= %d b=%d", a, b); return 0; }

Answer

Correct Answer: a=22 b=24

Note: This Question is unanswered, help us to find answer for this one

294. What will be output if you will execute following code? #include int main(){ float a=0.5, b=0.9; if(a&&b>0.9) printf("Sachin"); else printf("Rahul"); return 0; }

Answer

Correct Answer: Rahul

Note: This Question is unanswered, help us to find answer for this one

295. Which function is a System Call?

Answer

Correct Answer: close

Note: This Question is unanswered, help us to find answer for this one

296. What will be output if you will execute following code? #include int main(){ int x=25; if(!!x) printf("%d",!x); else printf("%d",x); return 0; }

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

297. memmove() is safer than memcpy() when it comes to the location of its arguments.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

298. What is the output of the Program : int main() { int i,j; i=1,2,3; j=(1,2,3); printf("%d %d",i,j); return 0; }

Answer

Correct Answer: 1 3

Note: This Question is unanswered, help us to find answer for this one

299. For a pointer to a 3 dimensional array (*foo)[2][3][4], how many calls to malloc do you need at least to allocate its contents?

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

300. #include int main(){ int a=0; #if (a==0) printf("Equal"); #else if printf("Not equal"); #endif return 0; } Output of above program is:

Answer

Correct Answer: Compilation error

Note: This Question is unanswered, help us to find answer for this one

301. The operator used to get value at address stored in a pointer "p" is :

Answer

Correct Answer: *p

Note: This Question is unanswered, help us to find answer for this one

302. What does malloc(0) return?

Answer

Correct Answer: The behavior is implementation-defined

Note: This Question is unanswered, help us to find answer for this one

303. What will this code print out? #include void function(char *name) { name=NULL; } main() { char *name="ELANCE"; function(name); printf("%s",name); }

Answer

Correct Answer: ELANCE

Note: This Question is unanswered, help us to find answer for this one

304. Which one is not a bitwise operator ?

Answer

Correct Answer: !

Note: This Question is unanswered, help us to find answer for this one

305. The main() function can be called recursively.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

306. What is the output of printf("%d\n", sizeof(long) / sizeof(int))?

Answer

Correct Answer: Depends on the implementation, but always some number >= 1.

Note: This Question is unanswered, help us to find answer for this one

307. To send an array as a parameter to function, which one is a right way:

Answer

Correct Answer: doThis(array)

Note: This Question is unanswered, help us to find answer for this one

308. What will be the output of the following? (int)b * (float)a / (double)d * (long)c

Answer

Correct Answer: double

Note: This Question is unanswered, help us to find answer for this one

309. stdarg.h defines?

Answer

Correct Answer: macros used with variable argument functions

Note: This Question is unanswered, help us to find answer for this one

310. What is the value of 1 & 2?

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

311. What will the following code print? void *p = malloc(0); printf ("%d\n", p);

Answer

Correct Answer: Unknown, it depends on what malloc will return.

Note: This Question is unanswered, help us to find answer for this one

312. What is the output of the following code? char * str1 = "abcd"; char * str2 = "xyz"; if( str1 < str2 ) printf( "1" ); else printf( "2" );

Answer

Correct Answer: Undefined

Note: This Question is unanswered, help us to find answer for this one

313. foo[4] is equivalent of :

Answer

Correct Answer: *(foo + 4)

Note: This Question is unanswered, help us to find answer for this one

314. With: sizeof(char *) == 4 sizeof(char) == 1 What will sizeof(plop) for char plop[2][3] be?

Answer

Correct Answer: 6

Note: This Question is unanswered, help us to find answer for this one

315. What are the different types of floating-point data in C ?

Answer

Correct Answer: float, double, long double

Note: This Question is unanswered, help us to find answer for this one

316. How can you access the first element of an array called 'arr'?

Answer

Correct Answer: (both of these)

Note: This Question is unanswered, help us to find answer for this one

317. Which statement is true about double?

Answer

Correct Answer: its size depends on the implementation

Note: This Question is unanswered, help us to find answer for this one

318. Will this loop terminate? int x=10; while( x-- > 0 );

Answer

Correct Answer: yes

Note: This Question is unanswered, help us to find answer for this one

319. What is the value of p in int a,b,*p; p=&a; b=**p; printf("%d",p);

Answer

Correct Answer: address of variable a

Note: This Question is unanswered, help us to find answer for this one

320. What will be the output of this Program? #include struct Data{ char a; char *data; int value; }; main() { printf("%d\n",sizeof(struct Data)); }

Answer

Correct Answer: It depends on the compiler and the hardware architecture.

Note: This Question is unanswered, help us to find answer for this one

321. The system function longjmp() can be used to return execution control to any user-specified point in the active function call tree.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

322. The end of a C statement is indicated by this character.

Answer

Correct Answer: ;

Note: This Question is unanswered, help us to find answer for this one

323. Which of the following is not a predefined variable type?

Answer

Correct Answer: real

Note: This Question is unanswered, help us to find answer for this one

324. which of these is not valid keyword?

Answer

Correct Answer: var

Note: This Question is unanswered, help us to find answer for this one

325. Which of the following is the correct operator to compare two integer variables?

Answer

Correct Answer: ==

Note: This Question is unanswered, help us to find answer for this one

326. int *a, b; What is b ?

Answer

Correct Answer: An int

Note: This Question is unanswered, help us to find answer for this one

327. Is C Object Oriented?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

328. int i = 17 / 3; what is the value of i ?

Answer

Correct Answer: 5

Note: This Question is unanswered, help us to find answer for this one

329. In C language, && is a

Answer

Correct Answer: Logical operator

Note: This Question is unanswered, help us to find answer for this one

330. int tab[3] = {0,1,2}; int i = 0; tab[++i] == ?

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

331. In C, a block is defined by...

Answer

Correct Answer: curly braces

Note: This Question is unanswered, help us to find answer for this one

332. If we pass an array as an argument of a function, what exactly get passed?

Answer

Correct Answer: Address of array

Note: This Question is unanswered, help us to find answer for this one

333. What does "int *p = malloc(2);" do?

Answer

Correct Answer: It will make p point to an uninitialized two-byte piece of memory allocated from the heap.

Note: This Question is unanswered, help us to find answer for this one

334. What is the value of the variable x? int x; x = 32 / 64;

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

335. What is i after the following block of code is executed : int i; i = 10/5/2/1;

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

336. #ifdef __APPLE__ # include <dir/x.h> #else # include <other_dir/x.h> #endif What does it mean?

Answer

Correct Answer: It will include dir/x.h if __APPLE__ is defined, or other_dir/x.h, otherwise.

Note: This Question is unanswered, help us to find answer for this one

337. How can you make an infinite loop in C?

Answer

Correct Answer: All answers are right.

Note: This Question is unanswered, help us to find answer for this one

338. Function Overloading is not supported in C.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

339. A C variable can start with a digit as well a letter.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

340. Which one is NOT a reserved keyword?

Answer

Correct Answer: intern

Note: This Question is unanswered, help us to find answer for this one

341. char* buf[100]; strcpy(buf, argv[1]); Which security risk is this code vulnerable to?

Answer

Correct Answer: Stack overflow

Note: This Question is unanswered, help us to find answer for this one