Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Practice InterviewNew Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Language in C Interview Questions and Answers

Ques 36. Can we get the mantissa and exponent form of a given number?

Ans. The function frexp( ) splits the given number into a mantissa and exponent form. The function takes two arguments, the number to be converted as a double value and an int to store the exponent form. The function returns the mantissa part as a double value. Following example demonstrates the use of this function.

#include <math.h>
#include <stdio.h>

void main( )
double mantissa, number ;
int exponent ;

number = 8.0 ;
mantissa = frexp ( number, &exponent ) ;

printf ( "The number %lf is ", number ) ;
printf ( "%lf times two to the ", mantissa ) ;
printf ( "power of %d\n", exponent ) ;

return 0 ;

Is it helpful? Add Comment View Comments
Ques 37. How do I write code that executes certain function only at program termination?
Ans. Use atexit( ) function as shown in following program.

#include <stdlib.h>
main( )
int ch ;
void fun ( void ) ;
atexit ( fun ) ;
// code
void fun( void )
printf ( "\nTerminate program......" ) ;
getch( ) ;
Is it helpful? Add Comment View Comments
Ques 38. What are memory models?
Ans. The compiler uses a memory model to determine how much memory is allocated to the program. The PC divides memory into blocks called segments of size 64 KB. Usually, program uses one segment for code and a second segment for data. A memory model defines the number of segments the compiler can use for each. It is important to know which memory model can be used for a program. If we use wrong memory model, the program might not have enough memory to execute. The problem can be solved using larger memory model. However, larger the memory model, slower is your program execution. So we must choose the smallest memory model that satisfies our program needs. Most of the compilers support memory models like tiny, small, medium, compact, large and huge.
Is it helpful? Add Comment View Comments
Ques 39. How does C compiler store elements in a multi-dimensional array?

Ans. The compiler maps multi-dimensional arrays in two waysâ??Row major order and Column order. When the compiler places elements in columns of an array first then it is called column-major order. When the compiler places elements in rows of an array first then it is called row-major order. C compilers store multidimensional arrays in row-major order. For example, if there is a multi-dimensional array a[2][3], then according row-major order, the elements would get stored in memory following order:
a[0][0], a[0][1], a[0][2], a[1][0], a[1][1], a[1][2]
Is it helpful? Add Comment View Comments
Ques 40. If the result of an _expression has to be stored to one of two variables, depending on a condition, can we use conditional operators as shown below?

( ( i < 10 ) ? j : k ) = l * 2 + p ;
Ans. No! The above statement is invalid. We cannot use the conditional operators in this fashion. The conditional operators like most operators, yields a value, and we cannot assign the value of an _expression to a value. However, we can use conditional operators as shown in following code snippet.

main( )
int i, j, k, l ;
i = 5 ; j = 10 ; k = 12, l = 1 ;
* ( ( i < 10 ) ? &j : &k ) = l * 2 + 14 ;
printf ( "i = %d j = %d k = %d l = %d", i, j, k, l ) ;

The output of the above program would be as given below:
i = 5 j = 16 k = 12 l = 1
Is it helpful? Add Comment View Comments

Most helpful rated by users:

©2018 WithoutBook