What are the difference between global and local variables?


Global Variable
Local Variable
Global Variable is variable which is declared before main function.
Local Variable is variable which is declared inside the main function or other functions.
A global variable can be accessed by all functions.

A local variable is isolated in its function.

It’s working with changing values.
It’s not working with changing values.
Variables treat(use) only one name in program.
Same variable names are working different values in different functions.
They are known to other functions and to the main program.
They are unknown to other functions and to the main program.

In what ways does a switch statement differ from an IF statement?



Ans: The if statement is a conditional branch, a branch to other statements if a certain condition or set of conditions is met. The condition can be logical or arithmetic.
 if (A>B)
 if else (C<D)
else j=14x7

 The switch statement (also known as a case statement) can branch to individual statements for a number of conditions or cases. it is more easily understood.
 switch case a>b... case c<d... case j=k... case else.. end

What is the difference between ++m and m++?



Ans:       If the Increment operator has placed before the operand it Increment first and other operations later. Example:
m=5      
x = ++m;
In this case first Increment the value of m and then transfer the value of m into x.
And
If the Increment operator has placed after the operand it Increment after the other operations. Example:
m=5      
x = m++;
In this case first transfer the value of m and then Increment the value of m.

Why shouldn’t these directives end with a semicolon?


Generally in c programming all the statements are end with semicolon for compiling. Headers are generally not compiled themselves but only for inclusion into *.cpp files.

What is the difference between --m and m--?



Ans:       If the decrement operator has placed before the operand it decrement first and other operations later. Example:
m=5      
x = --m;
In this case first decrement the value of m and then transfer the value of m into x.
And
If the decrement operator has placed after the operand it decrement after the other operations. Example:
m=5      
x = m--;
In this case first transfer the value of m and then decrement the value of m.