What are the different data types available in C or C++?

Data types are used to specify the type of values to be stored in the variables.
1. Int: Integer (int) data type is used to store the whole numbers i.e. numbers without decimal points. It takes two bytes of memory.
2. Char: Char data type is used to store only characters. A character may be a number, alphabet or any symbol. It takes one byte of memory to store one variable.
3. Long: This data type is also used for storing whole numbers but of higher range than that of int. It takes four bytes of memory.
4. Float: This data type is used to store real numbers and it takes four bytes of memory.
5. Double: It is another data type to store real numbers but of higher range than the float.

What is type casting?

Type casting is used to convert the data type from lower data type to higher data type and vice versa in order to perform operations with different data types in an expression.

Syntax:
Type variable1= (type)variable2;

Types of casting:
1. Implicit typecasting: Implicit typecasting is that typecasting which occurs automatically by the compiler when data type is converted into the higher type from lower.
Eg: short x=500;
Int y;
y=x;

2. Explicit typecasting: Explicit typecasting means that typecasting which does not occur automatically rather when they occur when programmer himself wants to convert a higher data type to lower type or vice-versa.
Eg: short x=500;
int y;
y = (int) x;

What are the different String functions available?

String Functions available in C:
1. Strlen (): strlen is used to find out the length of the string i.e. how many characters are there in string.
Syntax :strlen (str)

2. Strcpy (): strcpy() is used to copy one string to other string.
Syntax: Strcpy (str1, str);

3. Strcat (): strcat() is used to add one string at the end of another string. In other words it is used to join two strings.
Syntax: strcat (str, str1);

4. Strcmp(): strcmp() is used to make comparison between two strings. It returns 0 if both the strings are equal. Returns negative number if first string is less than second string. Returns positive number if first string is greater than second string
Syntax: strcmp(str,str1)

5. strlwr (): strlwr() is used to convert the whole string into lower characters.
Syntax: strlwr(str);

6. strupr ():strupr () is used to convert the whole string into upper characters.
Syntax: strupr(str)

7. Strrev(): strrev() is used to reverse the string.
Syntax: strrev(str)

What are Loop statements or Iteration Statements?

Loop statements are used to execute certain set of statements again and again in a program.
Different types of Loops:
1. While loop: While loop is used to execute the statements within it till the condition is true.
Syntax:
while(condition)
{
Statements;
}
2. Do while loop: Do while loop is also used to execute the statements till the condition is true but in this loop, statements will be executed first after that the condition will be checked. It will execute the statements at least one time even if the condition is false at the beginning.
Syntax:
do
{
statements;
}
While (condition);
3. For loop : In For loop, all the three parts of the loop that is initialization, condition and iteration are all written in a single statement. Initialization means initial value given to variable, condition upto which loop will execute and iteration is increment or decrement of value of variable.
Syntax:
For(initialization; condition; iteration)
{
Statements;
}

What is a header file?

Header files are used to store the inbuilt functions that are available in C or C++. If we want to use those inbuilt functions in our program we have to include that particular header file at the beginning of the program. For performing mathematical functions like square root (sqrt), sin, cos etc. we have to include the header file math.h.
Eg: printf (), scanf () are stored in header file stdio.h

What is a Union?

Union is quite similar to structure. Like structure, union is also used to store data of different data types. The only difference between structure and union is that in case of structure different variables are stored in their individual space in memory where as in case of Union total space that is required by the variables in memory is equal to the size of largest data type.
Eg: union student
{
int roll;
char name[10];
float marks;
}
The union student will take 10 bytes in memory that is equal to the size of largest variable.

What are the Branching Statements?

Branching statements are used to shift the control of the program from one part within the program to another part.

Types of Branching Statements:
1. Break statement
2. Continue statement
3. Goto statement

What are the different types of arguments?

Types of Arguments:

1. Actual Arguments: Actual arguments are the values of the variables that send at the time when functions are called.
2. Formal Arguments: Formal arguments are the variables in which the values of actual arguments that are send during function call are collected.

What is a Recursive function?

Recursion is the process of defining a function which calls itself from within its body. Recursive function is a function which calls itself again and again till the condition which is specified is true. In recursive functions we must give the terminating condition that is the limit upto which a function calls itself otherwise it will become an infinite loop that is a loop that never ends.
Eg of recursion : Program to calculate factorial of a number using recursion
# include
int factorial(int n)
{
if(n <= 1) return 1; else return n*factorial(n - 1); } void main() { int x = 5; printf("factorial of %d is %d",x,factorial(x)); }

What is Compile Time and Run Time?

Compile time is the time during which the compiler checks the errors of the program and trace out (display) errors if any. Compiling of a program is done using Alt+F9 in C and C++.

Run time (Execution time) is the time during which the compiler executes (runs) the program. Compiler executes the .exe file of program which is created after all the errors are removed. Execution of a program is done using Ctrl+F9 in C and C++.