C Interview Questions Part 25

Q:What is the difference between %d and %*d in c language?
A:%*d give the address of the variable.
eg:-
int a=10,b=20;
printf("%d%d",a,b);
printf("%*d%*d",a,b);
Result is 10 20 1775 1775
here 1775 is the starting address of the memory allocation for the integer.a and b having same address because of contagious memory allocation.
Q:What is difference between #include and #include"stdio.h"  ?
A: means its a in-built header file, "stdio.h" means
its an user-defined header file

Q:What is the difference between i++ and i+1 ? 
A:i++ is an increment and assign to i but i+1 is just an increment of i, but it doesnt mean the value in i got changed here.

Q:Difference between for loop and while loop? 
A:In for loop we should know initial &last condition.....but in while loop we only know the last condition....
ex. of for loop..for(i=0;i<=10;i++){
printf("%d",i);
}
ex. of while loop..while(i<=10){
printf("%d",i);
i++;
}
Q:Difference between structure and union?
A:Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members.

Q:Difference between *p and **p?
A:*p is a simple pointer which holds the address of another variable while **p is a double pointer which holds address of the pointer in which actual address of the another variable is stored.
Q:What is the difference between macros and inline functions?
A:Macro- does not involve in compilation if there is any logical error also just replaces the code inline- look like function, but control doesn't goes to function and execute, it simply replaces the code like macro but involves in compilation.