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

C Interview Question - DAY - 2

Uploaded by

Richa Dubey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

C Interview Question - DAY - 2

Uploaded by

Richa Dubey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

INTERVIEW QUESTIONS

1. Can we perform math operations on a void pointer?

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.

2. Why i++ execute faster than i+1?

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.

3. What is the use of bitwise operators?

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.

4. What are the restrictions of modulus operators in c?

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”.

Example: 5 % 2.5 // Error


5. What is the difference between SINGLE EQUAL “=” AND DOUBLE
EQUAL “==” OPERATORS IN C?

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.

Compiler compiles entire C source code into machine code.

Interpreters convert source code into intermediate code and then this
intermediate code is executed line by line.

7. What is the difference between pre-increment operator and


post-increment operator in C ? Also pre-decrement operator and
post-decrement operator in C ?

Ans. Pre increment operator is used to increment variable value by 1 before


assigning the value to the variable.

Post increment operator is used to increment variable value by 1 after


assigning the value to the variable.
Pre decrement operator is used to decrement variable value by 1 before
assigning the value to the variable.

Post decrement operator is used to decrement variable value by 1 after


assigning the value to the variable.

8. What is “&” and “*” operators in C?

Ans. “*” Operator is used as a pointer to a variable.

Example: * a where * is a pointer to the variable a.

“&” operator is used to get the address of the variable.

Example: &a will give the address of a.


9. What is the environment variable in C?

Ans - Environment variable is a variable that will be available for all C


applications and C programs. Once environment variables are exported, we can
access them from anywhere in a C program without declaring and initializing in
an application or C program.

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];

It declares a string variable named Name that can hold a maximum of 30


characters.
Follow us:

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

You might also like