Interview questions for c language


Q6: What is typecasting?

Ans: Typecasting is the process by which one data type is converted into another one called typecasting. If the floating type value is stored in an int type, the data type is explicitly converted into a different type.

Syntax:

(type_name) expression;

Q7: Write a program to swap two numbers without using the third variable.

Ans:

#include<stdio.h> #include<conio.h> main() { int a=10, b=20; clrscr(); printf("Before swapping a=%d b=%d",a,b); a=a+b; b=a-b; a=a-b; printf("nAfter swapping a=%d b=%d",a,b); getch(); }

//Output

Before swapping a=10 b=20

After swapping a=20 b=10

Q8: What is the difference between the expression “++a” and “a++”?

Ans: In the first term, the increase would initially take place on variable a, which will result in the value to be utilized. This is sometimes called an increase in the prefix. The current value of variable an in the second expression would be utilized in operation before increasing the values themselves. This is sometimes called an increase of postfixes.

Q9: Explain the # pragma directive.

Ans: The Pragma Directive provides the following points.

  • This is a directive you may use to activate or disable specific characteristics.
  • #pragma Startup enables you to specify functions when you start up a program.
  • The #pragma exit allows us to specify exit functions.
  • #pragma Warn helps to remove warnings from the computer or not.

Q10: Which structure is used to link the program and the operating system?

Ans: In the following points, the solution may be explained,

  • The structure used to link the OS to an application is a file.
  • The file is specified in the header "stdio.h" (the standard header file for input/output).
  • The file is utilized, the current size and its position in memory. It includes information.
  • It includes a character pointing to the opening character.
  • Opening a file provides a connection between the application and the operating system to access the file.