C Interview Questions Part 24

Q:What is void pointer?
A:Void pointer is the pointer which itself is null and can not be interchanged by others.
Ex-
{
int *a;
void *b;
*a=*b; //valid
a=b; //invalid
}

Q:What are the advantages of pointers?
A:Pointer variable is used to store the memory address of the another variable.Using pointers we can directly manipulate or access memory which is faster hence it increases execution time.

Q:What is the difference between structure and union?

A:union is unified memory where structure is non unified memory.All members of structure occupy consecutive chunks of memory and union members will share the most highest memory of the union member.i.e data type.we can access all the members of structure at a time but in union we can access a single union member at a time.

Q:Write a c program for greatest of three numbers without using if statement main( )?
A:{
int a,b,c,s1,big;
printf("enter 3 values");
scanf("%d %d %d", &a,&b,&c);
s1=(a>b)? a : b;
big= (s1>c)? s1 : c;
printf("largest of 3 no's=%d",big);
}
 
Q:What is the difference between definition and declaration? give me some example declaration?
A:for example,int i;
definition:
declaration as well as initialisation is known as definition
for example int i=25;

Q:What is the exact difference between '\0' and "" ?
A:'\0' is NULL character and "" is null string.

Q:Write a program to print infinite number?
A:void main(){
int i;
clrscr
();
for(i=0;;i++)
{
printf
("%d",&i);
}
getch
();
}