C Interview Question - DAY - 2
C Interview Question - DAY - 2
Ans. No, we cannot perform math operations on void pointers. This is because
addition and subtraction of pointers is based on advancing the pointer by the
number of elements. If we have a void pointer, we don’t know what it is
pointing to and so we don’t know the size of the location it is pointing to.
Therefore, we cannot apply math operations on a void pointer.
We can use character pointers, if we want pointer arithmetic to work on raw
addresses.
We can cast void to a char, do arithmetic and cast it back to a void.
Ans. The expression n++ requires single machine instruction to carry out
increment operation whereas n+1 requires multiple instructions to carry out
increment operation. therefore, the expression n++ gets executed faster than the
expression n+1.
Ans. Operating systems require the manipulation of data at addresses, and this
requires manipulating individual bits or groups of bits. For this purpose bitwise
operators are used. Bitwise operators allow us to read and manipulate bits in
variables of certain types. Bit wise operators only work on a limited number of
types. These are int and char.
Ans. As C language has three numerical data types integer, float and double but
modulus operator works only on integer but not on float or double. if we try to
use it on float or double we will get an error message as “Illegal use of
Floating Point”.
Ans. Single equal “=” is an assignment operator used to assign the values to
the variables.
Example:
double equal “==” is a relational operator used to compare two variable values
whether they are equal or not.
Example:
int x = 10;
int y = 10;
if(x == y){
printf(“true”);
}
6. What is the difference between ASSEMBLER, COMPILER AND
INTERPRETER?
Ans. Assembler is a program that converts assembly level language (low level
language) into machine level language.
Interpreters convert source code into intermediate code and then this
intermediate code is executed line by line.
10. How do you declare a variable that will hold string values
Ans. The char keyword can only hold 1 character value at a time. By creating an
array of characters, you can store string values in it.
Example:
char Name[30];
Website - https://ineuron.ai/
Linkedin -
https://www.linkedin.com/company/ineuron-ai/mycompany/
https://www.linkedin.com/in/saurabh-shukla-5b73bb6/
https://www.linkedin.com/in/prateek-jain-iitr/
Youtube Channel -
https://www.youtube.com/c/iNeuroniNtelligence
https://www.youtube.com/user/saurabhexponent1
https://www.youtube.com/c/PrateekJainAcademy