C Programming Interview Question and Answer SET 7





121. Predict the output or error
main()
            {
            int k=1;
            printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
            }
Ans: 1==1 is TRUE
Explanation: When two strings are placed together (or separated by white-space) they are concatenated (this is called as "stringization" operation). So the string is as if it is given as "%d==1 is %s". The conditional operator( ?: ) evaluates to "TRUE".

122. What is use of void data type?
Void is an empty data type normally used as a return type in C/C++, C#, Java functions/methods to declare that no value will be return by the function.
The another used of void is to declare the pointer in C/C++ where It is not sure what data type is addressed by the pointer.

123. four type of scope in c:
Block scope.
Function scope.
File scope.
Program scope.

124. Tell any five properties of auto variables?
auto variables are defined inside a function. A variable declared inside the function without storage class name is, by default, an auto variable. These functions are declared on the stack. The stack provides temporary storage.

125. What is automatic type promotion in c?
In c if two operands are of different data type in a binary operation then before performing any operation compiler will automatically convert the operand of lower data type to higher data type .This phenomenon is known as automatic type conversion. For example:
int a=10,c;
float b=5.5f;
c=a+b;
Here a int variable while b is float variable. So before performing addition operation value of the variable a (Lower data type) will automatically convert into float constant (higher data type) then it will perform addition operation.

126. What are differences between sizeof operator and strlen function?
sizeof is keyword of c which can find size of a string constant including null character but strlen is function which has been defined string.h and can find number of characters in a string excluding null character.  

127. What is command line argument?
Getting the arguments from command prompt in c is known as command line arguments.  In c main function has three arguments.
They are:
Argument counter
Argument vector
Environment vector

128. void main(){
    int x=5,y=10,z=15,val;
    val=sum(x,(y=0,z=0,y),z);
    clrscr();
    printf("%d",val);
    getch();
}
sum(int x,int y,int z){
    return x+y+z;
}
Answer:20
Explanation: In the above program comma after Y=0 &Z=0 are behaving as operator.

129. what is nested structure?
A structure is a collection of one or more variables, possibly of different data types, grouped together under a single name for convenient handling. Structures can contain other structures as members; in other words, structures can nest.

130. What is slack byte in structure?
To store any type of data in structure there is minimum fixed byte which must be reserved by memory. This minimum byte is known as word boundary. Word boundary depends upon machine. TURBO C is based on 8086 microprocessor which has two byte word boundary. So any data type reserves at least two byte space.

131.What is prototype of printf function?
 Prototype of printf function is:
 int printf( const char *format ,…)

132.What is difference between declaration and definition?
 During declaration we just specify the type and no memory is allocated to the variable. But during the
 definition an initial value is assigned and memory is allocated to the variable.

133. What is function recursion?
When a function of body calls the same function then it is called as 'recursive function.'
Example:
Recursion()
{
    printf("Recursion !");
    Recursion();
}

134. What is self referential structure ?
A self-referential structure is one of the data structures which refer to the pointer to (points) to another structure of the same type.

135. What is far pointer?
The pointer which can point or access whole the residence memory of RAM i.e. which can access all 16 segments is known as far pointer.

136. What is pascal and cdecl keyword in c language?
There are two types of parameters passing conventions in c:
1. pascal: In this style function name should (not necessary ) in the uppercase .First parameter of function call is passed to the first parameter of function definition and so on.
2. cdecl: In this style function name can be both in the upper case or lower case. First parameter of function call is passed to the last parameter of function definition. It is default parameter passing convention.

137. What is use of #pragma inline directive in c language?
#pragma inline only tells the compiler that source code of program contain inline assembly language code .In c we can write assembly language program with help of asm keyword.

138. What is the meaning of multilevel pointers in c?
A pointer is pointer to another pointer which can be pointer to others pointers and so on is known as multilevel pointers. We can have any level of pointers.

139. What is huge pointer in c?
The pointer which can point or access whole the residence memory of RAM i.e. which can access all the 16 segments is known as huge pointer.

140. Is it possible to rename any function in c?
Yes, we can rename any function using typedef keyword. It is useful when function declaration is too complex and we have to give any simple name or if we have to create more numbers of function of the same type.
 

Comments

Popular posts from this blog

Tips 01) self introduction in an interview

Computer Science Terminology

Why Failure Is Good for Success