C Langugage interview Qestions and Answers
1) Name the four basic data types in “C” language?
The four basic data types in “c” language are as follows
(i) Char
(ii) Int
(iii) Float
(iv) Double
2) Describe at least five different format specifiers?
%d: -An integer whole number
%f: -a floating point number
%c: -a single character
%p: -a machine memory address
3) Define and explain scanf () function?
The Scanf () function can be used to get input into a program and it requires two arguments. First a format specifier defines the type of data to be entered, then the name of the variable in which the input will be stored. This scanf () function is responsible for giving input into the program.
4) What are the maximum and minimum possible ranges of values for long and short type?
If the int variable is created by default as a ‘long’ type it typically will have a possible range of values from a maximum of +214748347 and a minimum of -2147483648. For ‘short’ type these are the maximum and minimum values +327676 and minimum -32768.
(While answering this question you can specify the approximate value raised to power).
5) What exactly is a ‘variable scope’, ‘local variables’ and ‘global variables’?
The extent to which a variable is accessible in a program is called the ‘variable scope’.
Variables declared internally inside a function are known as ‘local’ variables.
Variables declared externally outside a function are known as ‘global’ variables.
6) What are signed values?
When an int variable is declared it can by default contain either positive of negative integer values. These are known as ‘signed’ values. The range of positive values is determined by your system.
7) Explain about register variables relative to compiler?
A register variable declaration informs the compiler that the specified variable will be heavily used by the program. The intention is for the compiler to place register variables in the machine register of the computer to speed access times. Local internal variables can only be declared as register variables.
8) State some significant uses of arrays in C programming?
One of the most significant uses of arrays in c programming concerns with their ability to store strings of text. Each element in an array of the char data type can store a single character. Adding the special null character escape sequence in the arrays final element promotes the array to string. It can be referenced using the array name and can be displayed using the %s format specifier.
9) What is enum used for and state its format?
The enum keyword provides a handy way to create a sequence of integer constants in a concise manner. Optionally the declaration can include a name for the sequence after the enum keyword. The constant names follow with a comma and placed within braces. The name assigned can be used to call the function again at later stage. The constants can be assigned any individual value but the following constant will always increment it by one.
10) Explain about the constants which help in debugging?
A #if directive test can be offered with #else and #else if directives. This allows conditional branching of the program to run sections of the code according to the result. Constants defined with a #define directive can be undefined with the #undef directive. The #ifdef directive has a companion directive #ifndef. These commands can be useful when debugging problem code to hide and unhide sections of the program.
11) Define and explain about! Operator?
The logical operator! NOT is a unary operator that is used before a single operand. It returns the inverse value of the given operand so if the variable “c” had a value of true then! C would return value of false. The not operator is very much useful in C programs because it can change the value of variables with successful iterations. This ensures that on each pass the value is changed.
12) What is operator precedence?
Operator precedence defines the order in which C evaluates expressions.
e.g. in the expression a=6+b*3, the order of precedence determines whether the addition or the multiplication is completed first. Operators on the same row have equal precedence.
13) Explain about the functions strcat() and strcmp()?
This function concatenates the source string at the end of the target string. Strcmp() function compares two strings to find out whether they are the same or different. The two strings are compared character by character until there is a mismatch or end of one of the strings is reached, whichever occurs first. If in case two strings are identical, a value of zero is returned. If there is no matches between two strings then a difference of the two non matching values are returned according to ASCII values.
14) Why do we use structures?
We use structures for different purposes which are
1) Construct individual arrays
E.g. 1) one array for storing names, another array for storing prices, and another for storing number of pages.
2) Use a structure variable.
A structure contains a number of data types grouped together. These data types may or may not be of the same type.
15) State the difference between sprint () and sscanf() Functions?
The sprint() function works similar to the printf() function except for one small difference, instead of sending the output to the screen as printf() does, this function writes the output to an array of characters. Once str has been built, its contents can be displayed on the screen.
16) How do you write data to low level disk I/O?
In low level disk I/O, data cannot be written as individual characters, or as strings or as formatted data. There is only one way data can be written to read in low level disk I/O functions as buffer full of bytes. Writing a buffer full of data resembles the fwrite() function.
17) Define these functions fopen(), fread(), fwrite() and fseek()?
Fopen(): - On opening a file, a pointer is set up which points to the first record in the file.
Fread(): - The pointer moves to the next record while reading a file. It always reads the file where the pointer is pointed.
Fwrite(): -The pointer moves to the beginning of the next record on closing the file the pointer is deactivated. This pointer writes the record where the pointer is currently places.
Fseek(): - Function lets us move the pointer from one record to another.
18) State the difference between Unions and structures?
Both structures and unions are used to group a number of different variables together. But while a structure enables us treat a number of different variables stored at different places in memory, a union enables us to treat the same space in memory as a number of different variables.
19) What are the different styles present in WS_OVERLAPPEDWINDOW?
The different styles present in windows are WS_OVERLAPPED, WS_CAPTION, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX.
All these macros are #defined in the ‘windows.h’ header file.
20) What are the rules for constructing real constants?
Real constants are often called Floating point constants. The real constants could be written in two forms fractional form and exponential form.
These are the following rules while constructing real constants
1) A real constant must have at least one digit
2) It must have a decimal point
3) It could be wither positive or negative
4) Default sign is positive
5) No commas or blanks are allowed within a real constant.
The four basic data types in “c” language are as follows
(i) Char
(ii) Int
(iii) Float
(iv) Double
2) Describe at least five different format specifiers?
%d: -An integer whole number
%f: -a floating point number
%c: -a single character
%p: -a machine memory address
3) Define and explain scanf () function?
The Scanf () function can be used to get input into a program and it requires two arguments. First a format specifier defines the type of data to be entered, then the name of the variable in which the input will be stored. This scanf () function is responsible for giving input into the program.
4) What are the maximum and minimum possible ranges of values for long and short type?
If the int variable is created by default as a ‘long’ type it typically will have a possible range of values from a maximum of +214748347 and a minimum of -2147483648. For ‘short’ type these are the maximum and minimum values +327676 and minimum -32768.
(While answering this question you can specify the approximate value raised to power).
5) What exactly is a ‘variable scope’, ‘local variables’ and ‘global variables’?
The extent to which a variable is accessible in a program is called the ‘variable scope’.
Variables declared internally inside a function are known as ‘local’ variables.
Variables declared externally outside a function are known as ‘global’ variables.
6) What are signed values?
When an int variable is declared it can by default contain either positive of negative integer values. These are known as ‘signed’ values. The range of positive values is determined by your system.
7) Explain about register variables relative to compiler?
A register variable declaration informs the compiler that the specified variable will be heavily used by the program. The intention is for the compiler to place register variables in the machine register of the computer to speed access times. Local internal variables can only be declared as register variables.
8) State some significant uses of arrays in C programming?
One of the most significant uses of arrays in c programming concerns with their ability to store strings of text. Each element in an array of the char data type can store a single character. Adding the special null character escape sequence in the arrays final element promotes the array to string. It can be referenced using the array name and can be displayed using the %s format specifier.
9) What is enum used for and state its format?
The enum keyword provides a handy way to create a sequence of integer constants in a concise manner. Optionally the declaration can include a name for the sequence after the enum keyword. The constant names follow with a comma and placed within braces. The name assigned can be used to call the function again at later stage. The constants can be assigned any individual value but the following constant will always increment it by one.
10) Explain about the constants which help in debugging?
A #if directive test can be offered with #else and #else if directives. This allows conditional branching of the program to run sections of the code according to the result. Constants defined with a #define directive can be undefined with the #undef directive. The #ifdef directive has a companion directive #ifndef. These commands can be useful when debugging problem code to hide and unhide sections of the program.
11) Define and explain about! Operator?
The logical operator! NOT is a unary operator that is used before a single operand. It returns the inverse value of the given operand so if the variable “c” had a value of true then! C would return value of false. The not operator is very much useful in C programs because it can change the value of variables with successful iterations. This ensures that on each pass the value is changed.
12) What is operator precedence?
Operator precedence defines the order in which C evaluates expressions.
e.g. in the expression a=6+b*3, the order of precedence determines whether the addition or the multiplication is completed first. Operators on the same row have equal precedence.
13) Explain about the functions strcat() and strcmp()?
This function concatenates the source string at the end of the target string. Strcmp() function compares two strings to find out whether they are the same or different. The two strings are compared character by character until there is a mismatch or end of one of the strings is reached, whichever occurs first. If in case two strings are identical, a value of zero is returned. If there is no matches between two strings then a difference of the two non matching values are returned according to ASCII values.
14) Why do we use structures?
We use structures for different purposes which are
1) Construct individual arrays
E.g. 1) one array for storing names, another array for storing prices, and another for storing number of pages.
2) Use a structure variable.
A structure contains a number of data types grouped together. These data types may or may not be of the same type.
15) State the difference between sprint () and sscanf() Functions?
The sprint() function works similar to the printf() function except for one small difference, instead of sending the output to the screen as printf() does, this function writes the output to an array of characters. Once str has been built, its contents can be displayed on the screen.
16) How do you write data to low level disk I/O?
In low level disk I/O, data cannot be written as individual characters, or as strings or as formatted data. There is only one way data can be written to read in low level disk I/O functions as buffer full of bytes. Writing a buffer full of data resembles the fwrite() function.
17) Define these functions fopen(), fread(), fwrite() and fseek()?
Fopen(): - On opening a file, a pointer is set up which points to the first record in the file.
Fread(): - The pointer moves to the next record while reading a file. It always reads the file where the pointer is pointed.
Fwrite(): -The pointer moves to the beginning of the next record on closing the file the pointer is deactivated. This pointer writes the record where the pointer is currently places.
Fseek(): - Function lets us move the pointer from one record to another.
18) State the difference between Unions and structures?
Both structures and unions are used to group a number of different variables together. But while a structure enables us treat a number of different variables stored at different places in memory, a union enables us to treat the same space in memory as a number of different variables.
19) What are the different styles present in WS_OVERLAPPEDWINDOW?
The different styles present in windows are WS_OVERLAPPED, WS_CAPTION, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX.
All these macros are #defined in the ‘windows.h’ header file.
20) What are the rules for constructing real constants?
Real constants are often called Floating point constants. The real constants could be written in two forms fractional form and exponential form.
These are the following rules while constructing real constants
1) A real constant must have at least one digit
2) It must have a decimal point
3) It could be wither positive or negative
4) Default sign is positive
5) No commas or blanks are allowed within a real constant.
Comments
Post a Comment