C Programming Questions
C Programming Questions
C Programming Questions
Answers
Here we go.
Q #1) What are the key features in C programming language?
Portability – Platform independent language.
Modularity – Possibility to break down large programs into small modules.
Flexibility – The possibility to a programmer to control the language.
Speed – C comes with support for system programming and hence it is compiling
and executes with high speed when comparing with other high-level languages.
Extensibility – Possibility to add new features by the programmer.
Q #2) What are the basic data types associated with C?
Int – Represent number (integer)
Float – Number with a fraction part.
Double – Double-precision floating point value
Char – Single character
Void – Special purpose type without any value.
Q #3) What is the description for syntax errors?
Ans) The mistakes when creating a program called syntax errors. Misspelled commands or
incorrect case commands, an incorrect number of parameters when called a method
/function, data type mismatches can identify as common examples for syntax errors.
Q #4) What is the process to create increment and decrement stamen in C?
Ans) There are two possible methods to perform this task.
1) Use increment (++) and decrement (-) operator.
Example When x=4, x++ returns 5 and x- returns 3.
2) Use conventional + or – sign.
When x=4, use x+1 to get 5 and x-1 to get 3.
In this example Name of the function is Sum, the return type is integer data type and it
accepts two integer parameters.
This is called as cyclic nature and Char, int, long int data types have this property. Further
float, double and long double data types do not have this property.
Return Type -> Data type of the return value of the function.
Function Name -> The name of the function and it is important to have a meaningful
name that describes the activity of the function.
Parameters -> The input values for the function that need to use perform the
required action.
Function Body -> Collection of statement that needs to perform the required action.
Q #19) What is a pointer on a pointer in C programming language?
Ans) A pointer variable that contains the address of another pointer variable is called
pointer on a pointer. This concept de-refers twice to point to the data held by a pointer
variable.
Q #26) Explain the use of function toupper() with and example code?
Ans) Toupper() function is use to convert the value to uppercase when it uses with
characters.
Code –
Result –
Q #27) What is the code in while loop that returns the output of given code?
Q #28) What is the incorrect operator form following list(== , <> , >= , <=) and what is
the reason for the answer?
Ans) Incorrect operator is ‘<>'.This is the format correct when writing conditional
statements, but it is not a correct operation to indicate not equal in C programming and it
gives compilation error as follows.
Code –
Error –
Q #29) Is it possible to use curly brackets ({}) to enclose single line code in C
program?
Ans) Yes, it is working without any error. Some programmers like to use this to organize the
code. But the main purpose of curly brackets is to group several lines of codes.
Q #30) Describe the modifier in C?
Ans) Modifier is a prefix to the basic data type which is used to indicate the modification for
storage space allocation to a variable.
Example– In 32-bit processor storage space for int data type is 4.When we use it with
modifier the storage space change as follows.
Long int -> Storage space is 8 bit
Short int -> Storage space is 2 bit
Q #31) What are the modifiers available in C programming language?
Ans) There are 5 modifiers available in C programming language as follows.
Short
Long
Signed
Unsigned
long long
Q #32) What is the process to generate random numbers in C programming
language?
Ans) The command rand() is available to use for this purpose. The function returns any
integer number beginning from zero(0). Following sample code demonstrate the use of
rand().
Code –
Output –