Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Language in C Interview Questions and Answers

  Difficulty Level: AllBeginnerIntermediateExpert

Ques 1. What will be the output of the following code?

void main ()
{ int i = 0 , a[3] ;
a[i] = i++;
printf ("%d",a[i]) ;
}

Ques 2. Why doesn't the following code give the desired result?

int x = 3000, y = 2000 ;
long int z = x * y ;

Ques 3. Why doesn't the following statement work?

char str[ ] = "Hello" ;
strcat ( str, '!' ) ;

Ques 4. How do I know how many elements an array can hold?

Ques 5. How do I write code that reads data at memory location specified by segment and offset?

Ques 6. How do I compare character data stored at two different memory locations?

Ques 7. The Spawnl( ) function...

Ques 8. Are the following two statements identical?

char str[6] = "Kicit" ;
char *str = "Kicit" ;

Ques 9. Is the following code fragment correct?

const int x = 10 ;
int arr[x] ;

Ques 10. How do I write code to retrieve current date and time from the system and display it as a string?

Ques 11. How do I change the type of cursor and hide a cursor?

Ques 12. How do I write code that would get error number and display error message if any standard error occurs?

Ques 13. How do I write code to get the current drive as well as set the current drive?

Ques 14. The functions memcmp( ) and memicmp( )

Ques 15. How do I write code to find an amount of free disk space available on current drive?

Ques 16. How do I write a user-defined function, which deletes each character in a string str1, which matches any character in string str2?

Ques 17. How does free( ) know how many bytes to free?

Ques 18. What is the use of randomize( ) and srand( ) function?

Ques 19. How do I determine amount of memory currently available for allocating?

Ques 20. How does a C program come to know about command line arguments?

Ques 21. When we open a file, how does functions like fread( )/fwrite( ), etc. get to know from where to read or to write the data?

Ques 22. The sizeof( ) function doesnâ??t return the size of the block of memory pointed to by a pointer. Why?

Ques 23. Compare FP_SEG And FP_OFF.

Ques 24. How do I write a program to convert a string containing number in a hexadecimal form to its equivalent decimal?

Ques 25. How do I write code that reads the segment register settings?

Ques 26. What is environment and how do I get environment for a specific entry?

Ques 27. How do I display current date in the format given below?
Saturday October 12, 2002

Ques 28. If we have declared an array as global in one file and we are using it in another file then why doesn't the sizeof operator works on an extern array?

Ques 29. How do I write printf( ) so that the width of a field can be specified at runtime?

Ques 30. How to find the row and column dimension of a given 2-D array?

Ques 31. The access( ) function...

Ques 32. How do I convert a floating-point number to a string?

Ques 33. What is a stack ?

Ques 34. Allocating memory for a 3-D array

#include "alloc.h"
#define MAXX 3
#define MAXY 4
#define MAXZ 5
main( )
{
int ***p, i, j, k ;
p = ( int *** ) malloc ( MAXX * sizeof ( int ** ) ) ;
for ( i = 0 ; i < MAXX ; i++ )
{
p[i] = ( int ** ) malloc ( MAXY * sizeof ( int * ) ) ;
for ( j = 0 ; j < MAXY ; j++ )
p[i][j] = ( int * ) malloc ( MAXZ * sizeof ( int ) ) ;
}
for ( k = 0 ; k < MAXZ ; k++ )
{
for ( i = 0 ; i < MAXX ; i++ )
{
for ( j = 0 ; j < MAXY ; j++ )
{
p[i][j][k] = i + j + k ;
printf ( "%d ", p[i][j][k] ) ;
}
printf ( "\n" ) ;
}
printf ( "\n\n" ) ;
}
}
Data Structures
How to distinguish between a binary tree and a tree?

Ques 35. How do I use the function ldexp( ) in a program?

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

Ques 37. How do I write code that executes certain function only at program termination?

Ques 38. What are memory models?

Ques 39. How does C compiler store elements in a multi-dimensional array?

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 ;

Ques 41. How can I find the day of the week of a given date?

Ques 42. What's the difference between these two declarations?

struct str1 { ... } ;
typedef struct { ... } str2 ;

Ques 43. How do I print the contents of environment variables?

Ques 44. What would the second and the third printf( ) output the following program?

main( )
{
char *str[ ] = {
"Good Morning"
"Good Evening"
"Good Afternoon"
} ;
printf ( "\nFirst string = %s", str[0] ) ;
printf ( "\nSecond string = %s", str[1] ) ;
printf ( "\nThird string = %s", str[2] ) ;
}

Ques 45. How do I use scanf( ) to read the date in the form 'dd-mm-yy' ?

Ques 46. How do I print a floating-point number with higher precision say 23.34568734 with only precision up to two decimal places?

Ques 47. Are the expressions *ptr++ and ++*ptr same?

Ques 48. strpbrk( )

Ques 49. Can we convert an unsigned long integer value to a string?

Ques 50. ceil( ) and floor( )

Ques 51. How do I use function ecvt( ) in a program?

Ques 52. How to run DIR command programmatically?

Ques 53. Suppose I have a structure having fields name, age, salary and have passed address of age to a function fun( ). How I can access the other member of the structure using the address of age?

Ques 54. How to restrict the program's output to a specific screen region?

Ques 55. Sometimes you need to prompt the user for a password. When the user types in the password, the characters the user enters should not appear on the screen. A standard library function getpass( ) can be used to perform such function. Maximum number of characters that can be entered as password is 8.

Ques 56. How to obtain the current drive through C ?

Ques 57. How come the output for both the programs is different when the logic is same?

main( )
{
int i, j ;

for ( i = 1, j = 1 ; i <= 5, j <= 100 ; i++, j++ )
{
gotoxy ( 1, 1, ) ;
printf ( "%d %d", i, j ) ;
}
}

main( )
{
int i, j ;

for ( i =1, j = 1; j <= 100, i <= 5; i++, j++ )
{
gotoxy ( 1, 1 ) ;
printf ( "%d %d", i, j ) ;
}
}

Output -> 5 5

Ques 58. Can we get the x and y coordinate of the current cursor position ?

Ques 59. How do I programmatically delete lines in the text window?

Ques 60. How do I get the time elapsed between two function calls ?

Ques 61. How do I use swab( ) in my program ?

Ques 62. What does the error "Null Pointer Assignment" mean and what causes this error?

Ques 63. How to build an expression trees ?

Ques 64. Can we get the remainder of a floating point division ?

Ques 65. How to extract the integer part and a fractional part of a floating point number?

Ques 66. How do I define a pointer to a function which returns a char pointer?

Ques 67. What's wrong with the following declaration: char* ptr1, ptr2 ; get errors when I try to use ptr2 as a pointer.

Ques 68. How to use scanf( ) to read the date in the form of dd-mm-yy?

Ques 69. Why the output of sizeof ( 'a' ) is 2 and not 1 ?

Ques 70. Can we use scanf( ) function to scan a multiple words string through keyboard?

Ques 71. How to set the system date through a C program ?

Ques 72. How can I write a general-purpose swap without using templates?

Ques 73. What is a heap ?

Ques 74. How to obtain a path of the given file?

Ques 75. Can we get the process identification number of the current program?

Ques 76. How do I write a function that takes variable number of arguments?

Ques 77. Can we change the system date to some other date?

Ques 78. How to use function strdup( ) in a program?

Ques 79. On including a file twice I get errors reporting redefinition of function.
How can I avoid duplicate inclusion?

Ques 80. How to write a swap( ) function which swaps the values of the variables using bitwise operators.

©2016 WithoutBook