C Programming-C Coding Question Bank
C Programming-C Coding Question Bank
8. Write a C program to accept three integers and if sum of first two number is greater than
third number then display the difference else display the sum.
STRINGS
8 Write a function program in C to return the length of a string
9 Write a function sub program in C to join two string.
10 Write a function sub program in C to compare two string. Let the function return 0 if
they are lexicographically equal. If the first string is greater( comes after the second
string in the dictionary) let eh function return a positive number else a negative
number
11 Write a function sub program in C to make a duplicate copy of a given string
(fnStrCpy() )
12 Write a function sub program in C to convert a given string to upper case
(fnToUpper() )
13 Write a function sub program in C to convert a given string to lower case (fnToLower()
)
14 Write a function sub program in C to reverse a given string.
15
10 marks questions
1 An electric power distribution company charges domestic consumers as follows.
Let the program read customer number , name and the power consumed and print
4 Write a function to sort N numbers in an array using Bubble sort. Use it in the main
program to sort N numbers in an array. ( Input N numbers into an array, and display them
before sorting and after sorting )
5 Write a function to sort N numbers in an array using SELECTION sort. Use it in the
main program to sort N numbers in an array. ( Input N numbers into an array, and display
them before sorting and after sorting )
6 Write function programs to enter numbers into a N x M matrix and print the content
of the matrix. Write one more function to find the sum of two matrices Use them in
the main program to enter data into two matrices and find the sum of two matrices.
7 Write function programs to find the product of numbers in a M x P and PxN matrices.
Use that function in the main program to find the product of matrices with
dimensions: MxP and PxN.
8 Write function sub programs to INPUT, Print the content of and array containing N
numbers. Write one more function to return the standard deviation of N numbers in
an array. Write the main program in which you use these functions to input, print and
find the standard deviation of N numbers in an array.
StdDev= SQRT ( Σ( Xi – Avg)2/N )
9 Write a program in C to search for a given number in an array
10 Write flowchart and C program to input the Employee ID, Name and Basic
salary of an employee. Calculate GROSS and NET salaries as:
Gross = Basic + DA + HRA
Net = Gross –( IT + PF)
DA = 15% of Basic salary
HRA is 10% of the Basic + DA.
PF = 12% of the Basic.
IT ( Income Tax) is 500 if the (Basic + DA) is below Rs 10,000
It is 500 + 8% for the amount 10,000 and above( Basic + DA), but below
20,000. For any amount equal to and higher than 20,000 IT is 15% of
(Basic+DA).
The Parameters which are sent from main function to the subdivided function are
called as Actual Parameters and the parameters which are declared at the
Subdivided function end are called as Formal Parameters.
26 To store a negative integer, we need to follow the following steps. Calculate the
two’s complement of the same positive integer.
Ans: printf() is used to print the values on the screen. To print certain values,
and on the other hand, scanf() is used to scan the values. We need an
appropriate datatype format specifier for both printing and scanning purposes.
For example,
30 . What is an array?
Ans. The array is a simple data structure that stores multiple elements of the
same datatype in a reserved and sequential manner. There are three types of
arrays, namely,
31 What is /0 character?
Ans: Compiler is used in C Language and it translates the complete code into
the Machine Code in one shot. On the other hand, Interpreter is used in Java
Programming Langauge and other high-end programming languages. It is
designed to compile code in line by line fashion.
33 What is Dynamic Memory allocation? Mention the syntax.
Ans: Dynamic Memory Allocation is the process of allocating memory to the
program and its variables in runtime. Dynamic Memory Allocation process
involves three functions for allocating memory and one function to free the used
memory.
Syntax:
Syntax:
Syntax:
Syntax:
1 free(ptr);
Ans: We cannot use & on constants and on a variable which is declared using
the register storage class.
38 Write a simple example of a structure in C Language
Ans:
Factor Call by Value Call by Reference
Ans: Both the functions are designed to read characters from the keyboard and
the only difference is that
getch(): reads characters from the keyboard but it does not use any buffers.
Hence, data is not displayed on the screen.
getche(): reads characters from the keyboard and it uses a buffer. Hence, data
is displayed on the screen.
41 What do you mean by Memory Leak?
Ans: A local static variable is a variable whose life doesn’t end with a function
call where it is declared. It extends for the lifetime of the complete program. All
calls to the function share the same copy of local static variables
43 What is the difference between declaring a header file with < >
and ” “?
Ans: If the Header File is declared using < > then the compiler searches for the
header file within the Built-in Path. If the Header File is declared using ” ” then
the compiler will search for the Header File in the current working directory and
if not found then it searches for the file in other locations.
44 When should we use the register storage specifier?
Ans: We use Register Storage Specifier if a certain variable is used very
frequently. This helps the compiler to locate the variable as the variable will be
declared in one of the CPU registers.
Ans: Arrow Operator( -> ) can be used to access the data members of a Union
if the Union Variable is declared as a pointer variable.
Function Operation
To Open a
fopen()
file
In case you are facing any challenges with these C Programming Interview
Questions, please write your problems in the comment section below.
auto
register
static
extern
48 What is typecasting?
Ans: Typecasting is a process of converting one data type into another is known
as typecasting. If we want to store the floating type value to an int type, then we
will convert the data type into another data type explicitly.
Syntax:
1 (type_name) expression;
Ans:
Macro call replaces the templates with the expansion in a literal way.
The Macro call makes the program run faster but also increases the
program size.
Macro is simple and avoids errors related to the function calls.
In a function, call control is transferred to the function along with
arguments.
It makes the functions small and compact.
Passing arguments and getting back the returned value takes time
and makes the program run at a slower rate.