Category: C

C Question with Explanations

The Whole File:-C Questions with Explanations

1. void main()


int  const * p=5;




Compiler error: Cannot modify a constant value.


p is a pointer to a “constant integer”. But we tried to change the value

of the “constant integer”.

2. main()


char s[ ]=”man”;

int i;

for(i=0;s[ i ];i++)

printf(“\n%c%c%c%c”,s[ i ],*(s+i),*(i+s),i[s]);







s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same

idea. Generally  array name is the base address for that array. Here s is the base

address. i is the index number/displacement from the base address. So, indirecting it

with * is same as s[i]. i[s] may be surprising. But in the  case of  C  it is same as s[i].

3. main()


float me = 1.1;

double you = 1.1;


printf(“I love U”);



printf(“I hate U”);



I hate U


For floating point numbers (float, double, long double) the values

cannot be predicted exactly. Depending on the number of bytes, the precession with

of the value  represented varies. Float takes 4 bytes and long double takes 10 bytes.

So float stores 0.9 with less precision than long double.

Rule of Thumb:

Never compare or at-least be cautious when using floating point

numbers with relational operators (== , >, <, <=, >=,!= ) .

4. main()


static int var = 5;

printf(“%d “,var–);





5 4 3 2 1


When static storage class is given, it is initialized once. The change in

the value of a static variable is retained even between the function calls. Main is also

treated like any other ordinary function, which can be called recursively.

*****Many More*****


C interview Q & A

click the link to download the whole file:

C interview Q & A

MCQ Question Answers on C

Declarations and Initializations

Control Instructions


Floating Point Issues


C Preprocessor





Input output

Command Line Arguments

Bitwise Operators



Memory Allocation

Variable Number of Arguments

Complicated Declarations

Library Functions

Learn C Fundamentals

the whole book: C by Kerningan and ritche

C Questions
সৈকত ব্যানার্জ্জী

1. What does static variable mean?.
2. What is a pointer?
3. What are the uses of a pointer?
4. What is a structure?
5. What is a union?
6. What are the differences between structures and union?
7. What are the differences between structures and arrays?
8. In header files whether functions are declared or defined?
9. What are the differences between malloc () and calloc ()?
10. What are macros? What are its advantages and disadvantages?
11. Difference between pass by reference and pass by
12. What is static identifier?
13. Where is the auto variables stored?
14. Where does global, static, and local, register
15. Difference between arrays and linked list?
16. What are enumerations?
17. Describe about storage allocation and scope of
18. What are register variables? What are the advantages
19. What is the use of typedef?
20. Can we specify variable field width in a scanf()
21. Out of fgets() and gets() which function is safe to use and why?
22. Difference between strdup and strcpy?
23. What is recursion?
24. Differentiate between a for loop and a while loop? What are it uses?
25. What is storage class.What are the different storage classes in C?
26 What the advantages of using Unions?
27. What is the difference between Strings and Arrays?
28. What is a far pointer? where we use it?
29. What is a huge pointer?
30. What is a normalized pointer ,how do we normalize a pointer?
31. What is near pointer.
32. In C, why is the void pointer useful? When would you use it?
33. What is a NULL Pointer? Whether it is same as an uninitialized pointer
34. Are pointers integer ?
35. What does the error ‘Null Pointer Assignment’ means and what causes this error?
36. What is generic pointer in C?
37. Are the expressions arr and &arr same for an array of integers?
38. How pointer variables are initialized ?
39. What is static memory allocation ?
40. What is dynamic memory allocation?
41. What is the purpose of realloc ?
42. What is pointer to a pointer
.43. What is an array of pointers ?
44. Difference between linker and linkage ?
45. Is it possible to have negative index in an array?
46. Why is it necessary to give the size of an array in an array declaration ?
47. What modular programming ?
48. What is a function ?
49. What is an argument ?
50. What are built in functions ?
51. Difference between formal argument and actual argument ?
52. Is it possible to have more than one main() function in a C program ?
53. What is the difference between an enumeration and a set of pre-processor # defines?
54. How are Structure passing and returning implemented by the complier?
55. What is the similarity between a Structure, Union and enumeration?
56. Can a Structure contain a Pointer to itself?
57. How can we read/write Structures from/to data files?
58. Write a program which employs Recursion ?
59. Write a program which uses Command Line Arguments?
60. Difference between array and pointer ?
61. What do the ‘c’ and ‘v’ in argc and argv stand for?
62. What are C tokens ?
63. What are C identifiers?
64. Difference between syntax vs logical error?
65. What is preincrement and post increment ?
66. Write a program to interchange 2 variables without using the third one.
67. What is the maximum combined length of command line arguments including the space between adjacent arguments?
68. What are bit fields? What is the use of bit fields in a Structure declaration?
69. What is a preprocessor, What are the advantages of preprocessor ?
70. What are the facilities provided by preprocessor ?
71. What are the two forms of #include directive ?
72. How would you use the functions randomize() and random()?
73. What do the functions atoi(), itoa() and gcvt() do?
74. How would you use the functions fseek(), freed(), fwrite() and ftell()?
75. What is the difference between the functions memmove() and memcpy()?
76. What is a file ?
77. What are the types of file?
78. What is a stream ?
79. What is meant by file opening ?
81. What is a file pointer ?
82. How is fopen()used ?
83. How is a file closed ?
84. What is a random access file ?
85. What is the purpose of ftell ?
86. What is the purpose of rewind() ?
87. Difference between a array name and a pointer variable ?
88. Represent a two-dimensional array using pointer ?
89. Difference between an array of pointers and a pointer to an array ?
90. Can we use any name in place of argv and argc as command line arguments ?
91. What are the pointer declarations used in C?
92. Differentiate between a constant pointer and pointer to a constant ?
93. Is the allocated space within a function automatically deallocated when the function returns?

94. Discuss on pointer arithmetic?
95. What are the invalid pointer arithmetic ?
96. What are the advantages of using array of pointers to string instead of an array of strings?
97. Are the expressions *ptr ++ and ++ *ptr same ?
98. What would be the equivalent pointer expression foe referring the same element as a[p][q][r][s] ?
99. Are the variables argc and argv are always local to main ?
100. Can main () be called recursively?
101. Can we initialize unions?
102. What’s the difference between these two declarations?
103. Why doesn’t this code: a[i] = i++; work?
104. Why doesn’t struct x { … };x thestruct; work?
105. Why can’t we compare structures?
106. How are structure passing and returning implemented?

Continue reading

Download the Whole file


* * * * *

* * * * *

* * * * *

* * * * *

* * * * *



* *

* * *

* * * *

* * * * *



* *

* * *

* * * *

* * * * *



* *

* * *

* * * *

* * * * *

* * * *

* * *

* *




1 0 1

2 1 0 1 2

3 2 1 0 1 2 3

4 3 2 1 0 1 2 3 4

5 4 3 2 1 0 1 2 3 4 5


*****many more******

Download the Whole file

C Programs

C program to check perfect number

Perfect number program in c language

Armstrong number in c with output

C program to find given number is prime or not

How to print prime numbers from 1 to 100 in c

Sum of prime numbers from 1 to 100 in c

Write a c program to check whether a number is strong or not

Strong number program in c

C program to find whether a number is palindrome or not

Palindrome number in c language

C program to check if a number is palindrome using recursion

Write a c program to check given string is palindrome number or not
Quadratic equation in c language

How to find a b and c in a quadratic equation

Fibonacci series in c using for loop

C program to find factorial of a number

How to print Floyd’s triangle in c


C program to print Pascal triangle using for loop

Write a c program to print multiplication table

program to display ASCII values

program to print hello world without using semicolon

Reverse of a number in c using while loop

How to add two numbers without using the plus operator in c

Write a c program or code to subtract two numbers without using subtraction operator

Write a c program to find largest among three numbers using binary minus operator

Write a c program to find largest among three numbers using conditional operator

C program for generic root

C code for calculation of generic root in one line

Prime factor of a number in c

How to convert string to int without using library functions in c programming language

Program in c to print 1 to 100 without using loop

Can you write a c program without using main function?

  • We can write a c program without using main function. We can compile it but we cannot execute a program without a main function. Since in C execution of any program start from main function. Examples of c program without a main is all the c library functions. Function printf is an example of library function which has been written and complied without using main function. To use or run such functions we write other program using main function and call those functions.

******many more*******

The Whole File: C Question Answer

What is an lvalue?

An lvalue is an expression to which a value can be assigned. The lvalue expression is located on the left side of an assignment statement, whereas an rvalue is located on the right side of an assignment statement. Each assignment statement must have an lvalue and an rvalue. The lvalue expression must reference a storable variable in memory. It cannot be a constant. For instance, the following lines show a few examples of lvalues:

What is meant by “bit masking”?

Bit masking means selecting only certain bits from byte(s) that might have many bits set. To examine some bits of a byte, the byte is bitwise “ANDed” with a mask that is a number consisting of only those bits of interest. For instance, to look at the one’s digit (rightmost digit) of the variable flags, you bitwise AND it with a mask of one (the bitwise AND operator in C is &):

Are bit fields portable?

Bit fields are not portable. Because bit fields cannot span machine words, and because the number of bits in a machine word is different on different machines, a particular program using bit fields might not even compile on a particular machine.

Assuming that your program does compile, the order in which bits are assigned to bit fields is not defined. Therefore, different compilers, or even different versions of the same compiler, could produce code that would not work properly on data generated by compiled older code. Stay away from using bit fields, except in cases in which the machine can directly address bits in memory and the compiler can generate code to take advantage of it and the increase in speed to be gained would be essential to the operation of the program.

 Is it better to bitshift a value than to multiply by 2?

Any decent optimizing compiler will generate the same code no matter which way you write it. Use whichever form is more readable in the context in which it appears. The following program’s assembler code can be viewed with a tool such as CODEVIEW on DOS/Windows or the disassembler (usually called “dis”) on UNIX machines:

*****many more*******