Allunits Questionbank

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 24

C Programming – Question bank

KONGU ENGINEERING COLLEGE


PERUNDURAI – 638 052

QUESTION BANK

C PROGRAMMING
(07CE105 / 07ME105 / 07MT105 / 07EC105 / 07EE105 /
07EI105 / 07CS105 / 07IT105 / 07CH105 / 07FT105)

1
C Programming – Question bank

UNIT I
PART A
1. Access of several instructions at once is a ---------------- processing.
2. Laptop is a ---------------computer
3. FLOPS is-------------------
4. Computer require -----------to process data and store output
5. The physical form of output is known as --------------
6. Mention the examples of operating systems?
7. -------------is a software used to compose, format, edit and print electronic
document.
8. The spread sheet provides sheets containing the ------------
9. What is the expansion of GPRS?
10. What is the expansion of PSTN?
11. What is the expansion of ISTN?
12. What is the expansion of MSC?
13. What is the expansion of TCP/IP?
14. What is the expansion of VOIP?
15. What is a website?
16. What is a webpage?
17. Give the types of browsers?
18. What is expansion of URL?
19. High speed internet access ranging from -----------------------
20. -----------is a collection of similar objects.
21. What is the general format of an assembly instruction?
22. ---------is also known as the index page.
23. The development of computer can be divided into -----------generations.
24. Analytical engine was developed by-------------
25. UNIVAC is an example of------------
26. The unit that perform the arithmetic and logical operations on the stored numbers
is known as-------------
27. Linux is a type of ------------software.
28. Which of the following option is included in E-learning?
a. computer-based training b. web-based training
c. Both (a) and (b) d. None of these.
29. Which of the following activity can be termed as software piracy
a. Soft loading b. Counterfeiting
c. Renting d. All of these
30. ------------ is a programming language, which runs on the browser.
31. ------------ is a client-based language, which runs only on the internet explorer.
32. ASP scripts run on the -------------
33. ------------- is a web page developing language the enables programmer to create
customized tags.
34. computers work on a set of instruction called-------------
35. -------------- are one of the most basic tools that are used to develop the problem
solving logic.
36. -------------- is a pictorial representation on of an algorithm.

2
C Programming – Question bank

37. What is PDL?


38. A single program that is divided into small pieces called--------------
39. What is the meaning of morphos?
40. The semantic and syntax errors in the program are checked in ----------- phase.
41. Flow lines in a flowchart are used to connect---------------
42. Query languages comes under -------------generation.
43. Apple is an example of -----------computer.
44. Define VLSI?
45. -----------referred to as the brain of a computer system.
46. List the types of memories?
47. Secondary memory are also known as---------------
48. List the types of media?
49. What is the expansion of CBT and WBT?
50. Mention the first super computer developed by the Indians?

PART B
1. What is software piracy?
2. What are the advantages of transistors over vacuum tubes?
3. What is a newsgroup?
4. Distinguish between Internet and WWW?
5. Write short notes on Compiler?
6. Write short notes on Interpreter?
7. Write short notes on Linker?
8. Write short notes on Assembler?
9. Specify the application of computers?
10. Define parallel processing?
11. Define Artificial Intelligence?
12. What is meant by registers?
13. List out the various types of system software?
14. List out the various types of application software?
15. Mention the role of Information Technologies?
16. What is a web page?
17. Define a leased line?
18. List out any six flowchart symbol?
19. Mention the benefits of flowchart?
20. Define Encapsulation?
21. Define Inheritance?
22. Define Abstraction?
23. What is object?
24. What are all the characteristics of a good program?
25. Define a loader?
26. List the characteristics of second generation computer?
27. What is meant by hand-held computers?
28. Explain the types of memories?
29. What is meant by image editors?
30. What is meant by spread sheets?

3
C Programming – Question bank

31. What is DBMS?


32. Define firmware?
33. Define proprietary software?
34. Define open source software?
35. Define shareware?
36. List the types of freeware?
37. What is public domain software?
38. Distinguish between software upgrade and software update?
39. What is meant by software patch?
40. Explain E-learning?
41. Explain the E-learning modes?
42. What is the responsible for system analyst?
43. Define some of the domain types?
44. What is web server?
45. Distinguish between online and offline
46. Define the modem?
47. Explain broad band internet connection?
48. Define about Telnet?
49. Define Internet Relay Chat?
50. Explain video conferencing?

PART C
1. What do you understand by software? Discuss its types.
2. Explain the steps involved in the process of booting?
3. Explain how software is installed and uninstalled?
4. What is software piracy and how can it be avoided?
5. Discuss the various types of computers in detail.
6. Discuss the various computer generations along with the key characteristics of the
computer of each generation?
7. List the various services provided by the Internet?
8. Explain the roles of Information Technology?
9. Discuss the careers in Information Technology?
10. Briefly explain the Evolution of Internet?
11. Explain the Basic Internet terms?
12. Explain how we connect the internet and mention the types of internet
connection?
13. Explain the program development cycle?
14. What do you understand by problem solving techniques? Discuss its types.
15. Explain the program control structures?
16. What is meant by programming paradigms and explain its types?
17. Discuss the various programming language generations?
18. Explain in detail about the language translators?
19. Briefly explain the evolution of a computer?
20. Draw the block diagram of a computer and explain its basic organization?
21. Write the algorithm and draw the flowchart for the following:
i) To find the sum and average of two numbers

4
C Programming – Question bank

ii) To find the area of a triangle


22. Write the algorithm and draw the flowchart to find the solution of a quadratic
equation?
23. Write the algorithm and draw the flowchart to find the Prime numbers between
100 to 500?
24. Write the algorithm and draw the flowchart to find the Biggest of three numbers?
25. Write the algorithm and draw the flowchart to find the perfect squares from 1 to
500?
UNIT II
PART –A
1. What is the difference between ‘=’ and ‘= =’?
2. Give the precedence among Assignment operators.
3. What is the difference between %f and %g?
4. The expression containing all integer operands is called ----------.
5. Which operator cannot be used with real operands?
6. An expression that combine two or more relational expressions is
termed as --------- expression.
7. The --------- operator returns the number of bytes the operand occupies.
8. The use of _______ on a variable can change its type in the memory.
9. Which determines the order in which different operators in the expression are
evaluated?
10. What is the specification used to read or write a short integer?
11. The conversion specifier ________ is used to print integers in hexadecimal form.
12. What is the header file needed to include character functions?
13. For reading a double type value , we must use the specification ____________
14. The specification ________ is used to read a data from input list and discard it
without assigning it to many variables.
15. Give the specification used in scanf to terminate reading at the encounter of a
particular character.
16. The specification %[] is used for reading strings that contain ________.
17. By default, the real numbers are printed with a precision of _______ decimal
places.
18. How to print the data with left justified ?
19. The specifier ________ prints floating point values in the scientific notation.
20. What does getchar() do?
21. Give two library function to get input from user.
22. Mention any two built in function for string manipulation?
23. What is the use of islpha()?
24. Where is %0 used?
25. What is the use of 0 flag in output statements?
26. Who has written the Compiler for C?
27. Which language is predecessor for C?
28. What are the white space characters available in C?
29. Define the term variable.
30. Mention the qualifiers in C.
31. What are the size and sign qualifiers supported by a C compiler?

5
C Programming – Question bank

32. What is the difference between float and double data types?
33. Mention the basic data types supported in C with their range of values allowed for
them.
34. How many bytes are allocated for int, float, char and double?
35. Differentiate between \n and \r.
36. Write a C statement to declare constant of type int.
37. What is meant by keywords? Give example.
38. What is the ternary operator available in C?
39. Mention the difference between ‘a’ and “a”.
40. What the increment and decrement operators present in C?
41. Define the term operator and operand.
42. Write a C statement for the expression : i. c=(f-32) * 5
9
ii. a=2пr
43. What is the header file to be included for using scanf() and printf().
44. What is the use of clrscr()?
45. What is the header file that define pow()?
46. Why is C called structured programming language?
47. Differentiate between the constants and variables.
48. What is meant by initialization?
49. What is the difference between & and && as operators?
50. Give the output of the following
i. int i=10, j, k;
k=++i;
j=i++;
printf(“%d%d%d”,i,j,k);

PART – B
1. What are the relational and logical operators available?
2. What is the use of ternary operator?
3. Mention the unary operators and state their use.
4. Differentiate between logical and bitwise operators.
5. List the operators with the priority from highest to lowest.
6. What will be the value of ‘x’ after execution of the following program?
main()
{ int x=!0*10; }
7. What are formatted and unformatted functions?
8. What is the difference between character I/O and string I/O?
9. What are escape sequence characters?
10. List any four escape sequences with their uses.
11. Give the difference between puts() and putch().
12. What is the difference between getch() and getche()?
13. How is cgets() different from gets()?
14. How will you execute a doc command through C?
15. What is the use of exit() function?
16. Define Library function.

6
C Programming – Question bank

17. Mention some library functions with their purpose.


18. What are the flags used in output formatting?
19. Define an expression in C.
20. What are the two type of expression?
21. What is implicit type conversion?
22. What is explicit conversion?
23. Give some mathematical functions and their use.
24. How library functions are usually packaged within a C compiler?
25. In what general category do the #define and # include statements fall.
26. What are the format specifiers for int, float, double, long double, unsigned int,
short int?
27. Write the character set for C.
28. Give the syntax of scanf. Give examples.
29. Write C statement to display the following
Kongu
Engineering
College.
30. What are the different data types that are obtained by using qualifiers?
31. List few reserved words supported in C.
32. Give the output of the following
i. float f=10.1, g=2.345123
printf(“%f%f”,f,g);
33. What is meant by declaration?
34. What is the output of the following
i. int n1=32768.
printf(“ %d”, n1);
35. What is type casting? Give examples.
36. What is meant by an identifier?
37. What are the rules for declaring a variable?
38. List out the types of constants. Give example for each type.
39. What are the types of operators available in C?
40. What are the arithmetic operators present in C? Give example for each
41. Write 3 different C statements that add 1 to a variable.
42. List the arithmetic assignment operators present in C?
43. What is the use of % operator? Give an example.
44. What do you mean by binary operator? Give an example.
45. What is the difference between >> and << operators?.
46. Mention the use of comma(,) operator.
47. Write a short note on operator precedence.
48. What is an escape sequence?
49. What is the output of the following :
i. #include <stdio.h>
main()
{
int i1=10;
i1<<=1;

7
C Programming – Question bank

printf(“%d”,i1); }
50. What is the output of the following :
i. #include <stdio.h>
main()
{
int i1=1023.3456;
printf(“%d”,i1); }
51. Identify the errors in following :
i. #include <stdio.h>
main()
{
char x,y;
int z;
x=a;
y=b;
z=x+y;
printf(“%d”,z); }
52. Identify the errors in following :
i. #include <stdio.h>
main()
{
float area;
int r=4;
area=31.4 * r ** 2
printf(“%d”,area); }
53. Identify the errors in following :
i. #include <stdio.h>
main()
{
int r=4;
area=31.4 * pow(r,2);
printf(“%d”,area); }

PART C
1. Write in detail about the logical and relation operators supported in C with
example.
2. Write a C program to find the biggest of three numbers. Use conditional
operators.
3. Write a program to enter a number and carry out modular division operation by 2,
3 and 5 and display the remainders.
4. Write a program to convert the given decimal number to octal and hexadecimal.
5. Write a C program to input the rainfall of 3 consecutive days in cms and find its
average.
6. Find the Simple Interest? Inputs are principal amount, period in years and rate of
interest.

8
C Programming – Question bank

7. Write a program to get two times in hrs and mts.Add them and the result must be
in hrs and minutes.
8. Write a program to find the reverse of a given number.
9. Write a program to display list of C program files and directories. Use system()
function to execute DOS commands.
10. Write a program to enter the temperature in Fahrenheit and convert into celcius
and vice versa.
11. Summarize the purpose of flags that are commonly used with printf function.
Illustrate with examples.
12. Write a program to get a line of text and convert into upper or lower case without
using library functions.
13. Write a C program to print the Pascal’s triangle.
14. What are the different data types present in C. Consider the qualifiers too.
Mention the size and range supported by each of them. Also specify the format
specifier for each type. Give examples also.
15. Write a program in C to calculate simple and compound interest.
16. Write a C program to perform different arithmetic operations like addition,
subtraction, multiplication, division and finding reminder.
17. Explain in detail about the operator precedence.
18. With suitable examples, write about the bitwise operators supported in C.
19. Write a program in C to calculate area of the triangle
i. given the three sides
ii. give the base and height.
20. If a,b,c,d and e are declared using the statement
int a,b,c,d,e;
What is the value assigned to the variable a in the following statement.
a=b>c ? c > d ? 12 : d > e ? 13 : 14: 15 in each of the following cases:
i. b=5,c=15,d=e=8;
ii. b=15,c=10,d=e=8;
iii. b=15,c=10,d=e=20;
iv. b=c=9,d=20,e=19
21. Write a program to find the sum and average of 5 numbers.
22. Write in detail about type casting. Give examples
23. With examples, explain about various escape sequences.
24. Using conditional operator, write programs in C for the following
i. To find the maximum among two numbers.
ii. To fine whether a given number is odd or even.
iii. To fine whether a given number is positive or negative
25. Write a program to swap values of 2 variables with and without using temporary
variable.
UNIT III
PART A
1. What is sequential execution?
2. Give the syntax of simple if statement.
3. Give the flowchart of simple if statement.
4. Can a single if statement have more than one else construct.

9
C Programming – Question bank

5. What is break?
6. What is continue?
7. Give a difference between break and exit.
8. When does the default is executed in switch statement.
9. What would happen if break is not used in switch?
10. “It is not advisable to use unconditional statement in a program”. Comment.
11. Write a C program to check whether a number is divisible by 3 or not.
12. What is the output of the following code?
main()
{
int var = 3;
for (;var++=0;) printf(“%d”,var);
}
13. What is the output of the following code?
main()
{
int var1 = 0; int var1 = 20; char num1 = 1; char num2 = 10;
if (var1,var1,num1,num2)
printf(“computer”);
}
14. What is the output of the following program?
main()
{
int a = 10;
if (a=11)
printf(“True”);
else
printf(“False”);
}
15. Define loop.
16. How could you write infinite loop using for?
17. What is the output of the following code?
main()
{
unsigned int var = 10;
for (;var- >=10;)
printf(“%u”,var);
}

18. What is the advantage of if statement over switch statement?


19. What is the output of the program?
main()
{
float num = 1.5;
switch(num)
{

10
C Programming – Question bank

case 1: printf(“1”);
case 2: printf(“2”);
default: printf(“0”);
}
}
20. Can multiple values be used in case label list?
21. Give the reason for having control structures in C.
22. What are the data types that can be used for the selector of the case statement?
23. What is the output of the following statements
for(i = 10; i++; i<100)
printf(“%d \n”,i);
24. What is the output of the following statements?
for(i=0;i<10;i++);
printf(“%d\n”,i);
25. What is the difference between for and while loop.
26. What is the difference between while and do-while.
27. What is a comma operator? Within which control statement does the comma
operator usually appear?
28. How an individual array element identified?
29. What is the output of the following
int j;
while (j<=10)
{
printf(‘\n%d”,j);
j=j+1;
}
30. What is the output of the following?
int i=1;
while (i<=10);
{
printf(“\n%d”, i);
i++;
}
30. What is the output of the following?
main()
{
char ch;
for(ch=65; ch<=255; ch++)
printf("%d%c\n",ch,ch);
}
32. Write a C program to print the string “WordProcessing” in the following
format.
a. Word Processing
b. Word
c. W.P
33. What is the use of sscanf statement?

11
C Programming – Question bank

34. What is the use of sprintf statement?


35. What is the difference between getch() and getche()?
36. What is the difference between (! 0) and (! 1)? How while loop works with these
values?
37. What are the values of NULL and ! NULL?
38. Is it possible to use multiple while statement with do statement?
39. Give any two characteristics of an array.
40. What do you mean by predefined streams? List out them.
41. Give the syntax of three-dimensional arrays.
42. Give the syntax of multi-dimensional arrays.
43. What is the difference between sscanf() and scanf()?
44. What is the difference between sprintf() and printf()?
45. List out the operations frequently carried out by the arrays.
46. An array name contains base address of the array. Can we change the base
address of the array?
47. Can we store the values and address in the same array?
48. Mention the difference between character array and integer array.
49. What is the output of the following?
main()
{
unsigned int ch=0;
for(ch=65; ch<=255;)
printf("%d%c\n",ch,ch++);
}
50. What is the output of the following?
main()
{
float y=0.9;
long double z=0.9;
if (y == z)
printf("diamonds are forever");
else
printf("forever...forever");
}

PART B
1. Give the syntax of if-else statement.
2. Give the flowchart of the if..else construct.
3. Write a C program to find the greatest of two numbers.
4. Write a C program to find whether the given number is positive or negative.
5. Write a C program to find the smallest of two numbers.
6. Give the flowchart of continue statement.
7. List down the control statements supported by C language.
8. What is unconditional statement in C? Give its syntax.
9. Write down the sequence of actions performed when the goto statement is
executed.

12
C Programming – Question bank

10. Give the rules for defining label in goto statement.


11. Write a C program to check whether the given number is odd or even
12. Differentiate break and continue
13. Give the syntax of switch statement.
14. Write a C program to check whether the given character is a vowel or not using
switch.
15. Give the difference between the switch and nested if.
16. Draw the flowchart of the switch case statement.
17. List down the loop control statements available in C.
18. Give the importance of using loops in program.
19. Give the syntax of for loop.
20. What are the three actions performed in for loop.
21. Draw the flowchart representation of for loop.
22. Is it possible to create a for loop that is never executed?
23. Write a C program to display the number of a series 1,3,9,27,81….n by using for
loop.
24. Write a C program to find factorial of a number.
25. Write a C program to display sum of N natural numbers.
26. Give the syntax of while loop.
27. How many control variables can be used in a for loop? Justify with an example.
28. Write an equivalent if structure for implementing a for loop.
29. Write an execution sequence of for loop with an example.
30. Why is the use of the goto statement generally discouraged? Under what
conditions might the goto statement be useful?
31. In what way does an array differ from an ordinary variable?
32. Rules for writing a one-dimensional array definition.
33. What advantage is there in defining an array size in terms of a symbolic constant
rather than a fixed integer quantity?
34. Write a C Program to print the string “How Are U” in the following format
a.How Are U
b.H.A.U
c. How
Are
U
35. Define array and give its types.
36. What does the statement continue do in a do-while loop?
37. What does the statement break do in a do-while loop?
38. Draw the flowchart for while loop.
39. Draw the flowchart for while loop.
40. How will you initialize a two-dimensional array?
41. Write the other name for while loop?
42. Write the other name for while loop?
43. What do you mean by entry controlled loop?
44. What do you mean by entry controlled loop?
45. Write a C program to display the following

13
C Programming – Question bank

*
* *
* * *
46. Write a C program to read a matrix and display the matrix using array.
47. Write a C program to check whether a given year is a leap year or not.
48. Write a C program to check whether the entered character is an uppercase or
lowercase letters or digits.
49. Write a C program to check whether the triangle is isosceles, equilateral, scalene
or right angled triangle.
50. Write a program to check whether a given number is divisible by 7 or not.

PART C
1. Explain the control statements available in C with its syntax.
2. Write a C program to calculate the electricity bill by accepting the starting and
ending meter reading.
3. Write a menu driven program to perform the functions of a calculator.
4. Explain switch statement.
5. Write a C program to display the multiplication table of a number given by user.
6. Write a C program to generate fibonacci series.
7. Write a C program to check whether a given number is prime or not.
8. Write a C program to display the pascals triangle.
9. Write a C program to find the roots of a quadratic equation.
10. Write a C program that reads in N numbers and find the smallest and greatest
number.
11. Write a C program to process the marks obtained by a student and also display the
class obtained by them.
12. Explain for statement and explain its working.
13. Write a C program to check whether the given matrix is symmetric
(Hint: Matrix A = Transpose of Matrix A)
14. Write a C program to count the number of vowels and consonants in a character
array (String).
15. Write a C program to convert the individual character in a string in to its
equivalent ASCII values
16. Write a C program to get 5 numbers and find out whether they are prime number
or not.
17. Write C program to find the factorial of N numbers using do-while loop.
18. Write a C program to display series of numbers as given
1
2 1
3 2 1
4 3 2 1
4 3 2 1
3 2 1
2 1
1
19. Write a C program to multiply two 3*3 matrices.

14
C Programming – Question bank

20. Write a C program to add the digits of a given number.


21. Write a C program to print the multiplication table for any given number.
22. Write a C program to read a three digit number and generate possible
permutations(eg., if n=123 output is 123,132,213,231,312,321)
23. Write a C program to count the number of words, characters and number of lines
in a text.
24. Write a C program to sort the given numbers in both ascending and descending
order.
25. Write a C program to read N numbers and find the count of positive, negative and
zero numbers.

UNIT IV
PART-A
1. We can use the conversion specification _______ in scanf to read a line of text.
2. We can initialize a string using the string manipulation function_______.
3. The function strcat has _______ parameters.
4. To use the function atoi in a program we must include the header file _______.
5. The function _______ does not require any conversion specification to read a string
from the keyboard.
6. The function ________ is used to determine the length of the string.
7. The ________ string manipulation function determines if a character is contained in a
string.
8. The function _______ is used to sort the strings in alphabetical order.
9. The function call strcat(s2,s1) appends ____ to _____.
10. The printf may be replaced by ________ function for printing strings.
11. The header file _____ is required when using character handling functions.
12. Strings are ______ of characters.
13. The characters of the string are enclosed within a pair of _____.
14. A ______ character terminates the string.
15. The function ______ compares two strings.
16.The parameters used in a function call are called _______.
17. A variable declared inside a function is called ____.
18.By default, ______ is the return type of a C function.
19. In passing by pointers, the variables of formal parameters must be prefixed with
_____ in their declaration.
20. In prototype declaration specifying ______ is optional.
21. _____ refers to the region where a variable is actually available for use.
22. A function that calls itself is known as a _______ function.
23. If a local variable has to retain its value between calls to the function, it must be
declared as ______.
24. A _______ aids the compiler to check the matching between the actual arguments and
the formal ones.
25. A variable declared inside a function by default assumes ______ storage class.
26. Find the error in the following function call: xyx(void);
27. A ____ must always follow the closing brace of the function declaration.
28. A pointer variable contains as its value the ______ of another variable.

15
C Programming – Question bank

29. The ______ operator is used with a pointer to dereference the address contained in the
pointer.
30. The ______ operator returns the value of the variable to which its operand points.
31. The only integer that can be assigned to a pointer variable is ______.
32. The pointer that is declared as ______ can’t be dereferenced.
33. ______ directive defines a macro substitution.
34. The output of the _______ is processed by the actual compiler.
35. The _______ directive discards a macro.
36. A _______ refers to a C program with all its header files.
37. An _______ variable does not retain its value once control is transferred out of its
defining function.
38. External variables are often referred to as ________.
39. _______ is the programming concept where in the use of pointers becomes
indispensable.
40. All variables that can be accessed directly (by their names) can also be accessed
indirectly by means of ______.
41. Functions that have been already written compiled and placed in libraries are called
_______.
42. Function declarations are also called _______ since they provide the model of the
function.
43. ______ are the means of communication between the calling and called functions.
44. The variables defined in function definition are known as _________.
45. Variables that specify the values that are passed to the function are called ______ in a
function call.
46. The process of assigning the address of a variable to a pointer variable is known as
_______.
47. Subsequent occurrence of a macro with arguments is known as _______.
48. The return type must be _______ if no value is returned.
49. The indirection operator (*) is also known as __________.
50._______ refers to the accessibility of a variable from the memory.

PART-B
1. Mention the common operations that can be performed on character strings.
2. List the limitations of using getchar and scanf functions for reading strings.
3. What will be the output of the following statement?
printf(“%d”,strcmp(“push”,”pull”));
4. Compare the working of strcpy and strncpy.
5. What will be the output of the following code?
char s1[]=”INFORMATION” ;
char s2[]=”TECHNOLOGY”;
printf(strstr(s1,s2));
6. Compare the operations of strcat and strncat.
7. Write a program to extract a portion of a character string and print the extracted
string.
8. How the functions in C are classified?
9. What are functions?

16
C Programming – Question bank

10. The main is a user-defined function.How does it differ from other user-defined
functions?
11. What is prototyping? Why is it necessary?
12. Distinguish between actual and formal arguments.
13. When a function is said to be recursive? Also specify where it can be used?
14. Mention the different ways of passing parameters to functions.
15. How can you differentiate scope and visibility of variables?
16. Write a C program to multiply two numbers.
17. Write a function prime that returns 1 if its argument is a prime number and returns
0 otherwise.
18. Write a function that will scan a character string passed as an argument and
convert all lowercase characters into their upper case equivalents.
19. Distinguish between (*m)[5] and *m[5].
20. Do the declarations char s[5]; char *s; represent the same, Explain.
21. Which one of the following is the correct way of declaring a pointer to a function?
Why? a) int (*p) (void); b) int *p (void);
22. What are the differences between procedure and function.
23. When are sub programs used as parameters.
24. What is mutual recursion?
25. What are the differences between direct and indirect invocation?
26. Explain briefly the concept of call by value and call by reference parameters.
27. What are the three parts of recursive definition?
28. What is the necessity of a return statement? when is it necessary and when is it
must?
29. What are the advantages of modular programming?
30. What do you understand by nesting of subprograms?
31. What would be the output of the following program?
main()
{
int num;
num=func(20);
printf(“%d” ,num);
}
int func(int num)
{
num>20?return(100):return(200);
}
32. What would be the output of the following program?
main()
{
printf(“\n computer”);
main();
}
32. What is the difference between a function declaration and a function definition?
33. Distinguish between recursion and iteration.
34. Write a program to concatenate two strings.

17
C Programming – Question bank

35. Write a program that inverts the given string.


36. What is the function of a pointer variable? What are its uses?
37. What is meant by a scope of the pointer variable?
38. What is meant by dereferencing? What is the difference between a pointer and a
dereferenced pointer?
39. What is special about void pointers?
40. What do you understand by a pointer to a pointer?
41. What are the functions of a preprocessor?
42. What is a translation unit?
43. Write a program to accept a string and print the address of its beginning location
44. What is the output of the following code?
main()
{
int num,*p;
num=5;
p=&num;
printf(“%d”,*p);
}
45. Differentiate malloc and calloc.
46. What is meant by dynamic allocation.
47. What are the dynamic memory allocation functions in C?
48. What happens if a termination condition in recursive definition is incorrect?
49. What is meant by parameter passing mechanism?
50. What are the strategies of parameter passing in C?

PART C
1. Write a program, which reads your name from the keyboard and outputs a list of
ASCII codes, which represent your name.
2. Write a program to do the following:
a) To output the question “Who is the inventor of C?”
b) To accept an answer.
c) To print out “Good” and then stop, if answer is correct.
3. Write a program to extract a portion of a character string and print the extracted
string. Assume that m characters are extracted,starting with the nth character.
4. Write a program which will read a text and count all occurrences of a particular
word.
5. Write a program which will read a string and rewrite it in alphabetical order.For
example, the word STRING should be written as GINRST.
6. Write a program that reads a string from the keyboard and determines wheter the
string is a palindrome or not.
7. Write a program to read two strings and compare them using strncmp() and print a
message that the first string is equal, less, or greater than the second one.
8. Write a program to read a line of text from the keyboard and print out the number
of occurrences of a given substring using the function strstr().
9. Write a program to create a directory of students with roll numbers. The program
should display the roll number for a specified name and vice-versa.

18
C Programming – Question bank

10. Given a string


Char str[]=”123456789”;
Write a program that displays the following:
1
232
34543
4567654
567898765
11. Write a function exchange to interchange the values of two variables, say x and y.
Illustrate the use of this function, in a calling function. Assume that x and y are
defined as global variables.
12. Write a function that will generate and print the first n Fibonacci numbers. Test
the function for n=5, 10, and 15.
13. Write a function that will round a floating-point number to an indicated decimal
place. For example the number 17.547 would yield the value 17.55 when it is
rounded off to two decimal places.
14. Develop your own functions for performing following operations on strings:
(a) Copying one string to another.
(b) Comparing two strings.
(c) Adding a string to test your functions.
15. Write a program using pointers to read in an array of integers and print its
elements in reverse order.
16. Write a function that receives a sorted array of integers and an integer value, and
inserts the value in its correct place.
17. Write a function using pointers to add two matrices and to return the resultant
matrix to the calling function.
18. Using pointers, write a function that receives a character string and a character as
argument and deletes all occurrences of this character in the string. The function
should return the corrected string with no holes.
19. Write a function (using a pointer parameter) that reverses the elements of a given
array.
20. Write a function (using pointer parameters) that compares two integer arrays to
see whether they are identical. The function returns 1 if they are identical, 0
otherwise.
21. Write a nested macro that gives the minimum of three values.
22. Define a macro with one parameter to compute the volume of a sphere. Write a
program using this macro to compute the volume fro spheres of radius 5, 10 and
15 metres.
23. Define a macro that receives an array and the number of elements in the array as
arguments. Write a program using this macro to print out the elements of an array.
24. Define symbolic constants for {and} and printing a blank line. Write a program
using these constants.
25. Write symbolic constants for the binary arithmetic operators +,-,* and /. Write a
program to illustrate the use of these symbolic constants.

19
C Programming – Question bank

UNIT V
PART A
1. Typedef is _______ datatype.
2. Write the syntax for typedef.
3. The _______ can be used to create synonym for a previously defined data type.
4. A _______ is a collection of data items under one name in which the items share the
same storage.
5. The name of a structure is referred to as _______.
6. The selection operator  requires the use of a _____to access the members of a
structure.
7. The variables declared in a structure definition are called its _______.
8. The keyword _______ must precede a structure name.
9. The precedence of the member operator is _______ than all arithmetic and relational
operators.
10. Structures within a structure mean ________.
11. All members of a _______ use the same location.
12. Structure member can be accessed by writing ________.
13. ________ structures are very useful in applications that involve linked data structures
such as lists and trees.
14. Unions are used to conserve _______.
15. ______ is the place on the disk where a group of related data is stored.
16. The ______ function is used to create new file/opens an existing file for use.
17. A file name contains _______ and _______ with the extension.
18. The _______ function is used to write a character to a file.
19. getw and putw are _______ functions in file management in C.
20. _______ takes a file pointer and resets the position to the start of the file.
21. The mode _______ is used for opening a file for updating.
22. The function ________ may be used to position a file at the beginning.
23. The function ________ gives the current position in the file.
24. EOF is integer type with the value _______.
25. The function ________ can be used to test for an end of file condition.
26. The functions _______ and _______ perform I/O operations in files.
27. The library function ______ closes a file.
28. Data structure of a file is defined as ______ in the library of standard input, output
function definitions.
29. _______ and _______ are two distinct ways to perform file operations in C.
30. The low level I/O operations uses _______ to perform file operations in C.
31. The process of emptying the buffer by writing its contents to disk is called ______.
32. A ____ is always associated with a file while reading or writing.
33. The process of feeding the output of one program to the input of another program so
that both the programs run simultaneously is called ________.
34. The pointer variable in file operations which indicates the beginning of the buffer
area is often referred to _______.
35. _______ is storage where information is temporarily stored while being transferred
between computer’s memory and data file.
36. The buffer area is established by writing ________.

20
C Programming – Question bank

37. Heterogeneous user-defined data type in C is _______.


38. The structure declaration starts with the _______ that consists of the keyword struct
followed by a tag.
39. Members of a structure can be accessed using both the ______ and ______ operators.
40. While declaring enumerated data type the values enclosed within braces are called
________.
41. _______ allows users to define an identifier that would represent an existing data
type.
42. A structure is a convenient tool for handling a group of _______.
43. The template of a structure should terminate with a ______.
44. In structure template we can’t initialize _______ members.
45. General format of sending a copy of a structure to the called function is ________.
46. The unary operator ________ tells us the size of the structure.
47. Passing structures to functions by _______ is more efficient than passing by value.
48. A _____ is set of adjacent bits whose size can be from 1-16 bits in length.
49. Data related to numbers can be efficiently stored in the form of _____ files.
50. Mention any one of the file-handling functions.

PART-B
1. What is meant by user-defined data type? Give an example.
2. Differentiate user-defined data types and built-in data types.
3. What are enumeration constants.
4. Define structure with example.
5. Define Union with example.
6. Differentiate structure and union.
7. How is a structure different from an array?
8. Why a structure is called a heterogeneous data type?
9. What is the size of union over structure?
10. Can the name of the fields of two different structures be the same.
11. What are nested structures? and How they are defined?
12. How do we initialize structures during declaration? Give an example.
13. How do we pass a structure as a parameter to functions?
14. Explain the difference between two member access operators in structures.
15. What are bit fields? How are they useful?
16. Can a structure variable be assigned to another? If so, what is the restriction.
17. Can we define a structure within a union?
18. What is the use of typedef in structure?
19. How are arrays of structures defined?
20. What is output of the following code?
main()
{
struct strc{
long int i;
char str[4];
};
struct strc s1;

21
C Programming – Question bank

strc.i=512;
printf(“%d%d%d”, s1.str[0],s1.str[1],s1.str[3]);
}
21. What is meant by self referential structure? Give an example.
22. Differentiate getc(), getchar() and getch().
23. What is meant by random accessing a file?
24. What are the file modes available in C?
25. What is the use of ftell(),fseek() in file handling?
26. Mention the difference between fwrite() and fprintf().
27. Mention the difference between fread() and fscanf().
28. What is meant by command line arguments? Give an example.
29. What is meant by binary files?
30. Differentiate formatted and unformatted file operations.
31. What is meant by macros? and its use.
32. What values are stored in argc() and argv().
33. What are the three steps that are followed while accessing a file?
34. What is the difference between buffered and unbuffered file I/O functions?
35. What are the bitwise operations and operators?
36. How will you open a file?
37. When do we use the following functions? free(), rewind().
38. What is the use of following functions? feof(), ferror().
39. What does the following statement mean?
FILE (*p) (void)
40. What does the following statement mean?
While((c=getchar)!=EOF)
41. What does the following statement mean?
While((m=getw(f1) )!=EOF)
Printf(“%5d”,m);
42. What does the following segment do?
……….
for(i=1;i<=5;i++)
{
fscanf(stdin,”%s”,name);
fprintf(fp,”%s”,name);
}
………..
43. What are the file operations?
44. What is meant by redirection operator in C? How will they use?
45. What is a file? Why is a file called as an external data structure?
46. What are the three steps are followed while accessing a file?
47. Mention two differences between text file and binary file.
48. What are the two possible ways in which a data can be written to a file? Give an
example.
49. List out the possible errors that occur during file handling.
50. Write a program to copy the contents of one file to another file.

22
C Programming – Question bank

PART C
1. Define a structure data type called time_struct containing three members integer
hour, integer minute and integer second. Develop a program that would assign
values to the individual members and display the time in the following form:
16:40:51.
2. Define a structure data type named date containing three integer members day,
month, and year. Develop an interactive modular program to perform the
following tasks
(i) To read the data into structure members by a function.
(ii) To print the date in the format April 29, 2008 by a function.
(iii) To validate the date entered by another function.
3. Write a program to process student record by using structures.
4. Define a structure called CRICKET that contains player name, team name and
batting average. Using cricket, declare an array player with 50 elements and write
a program to read the information about all the 50 players and print a team-wise
list containing names of players with their batting average.
5. Define a structure that can describe a hotel. It should have members that include
name, address, grade, average room charge and number of rooms .Write functions
to perform following operations: (i) To print out hotels of a given grade in order
of charges.
6. Define a structure type, struct personal that would contain person name, date of
joining and salary. Using this structure write a program to read this information
for one person from the keyboard and print the same on the screen.
7. Write a program to illustrate the comparison of structure variables.
8. For a student array write a program to calculate the subject-wise and student-wise
totals and store them as a part of structures.
9. Write a simple program to illustrate the method of sending an entire structure as a
parameter to a function.
10. Write a program for the demonstration of returning structures from functions.
11. Write a program to find a customer record that corresponds to a specified account
number.
12. Write a program to read the data from the keyboard, write it to a file called input,
again read the same data from the input file and display it on the screen.
13. A file named DATA contains a series of integer numbers. Code a program to read
these numbers and then write all odd numbers to a file to be called ODD and all
even numbers to a file called EVEN.
14. Write a program to open a file named INVENTORY and store the following data;
item name number price quantity
aaa 111 17.50 100
bbb 222 20.75 150
Extend the program to read this data from the file inventory and display the
inventory table with the value of each item.
15. Write a program to create and count number of characters in a file.
16. Write a program to convert the case of alphabets in a text file. Upper case letters
should be converted to lower case and vice versa.
17. Write a program to illustrate error handling in file operations in C.

23
C Programming – Question bank

18. Write a program that uses the functions ftell() and fseek().
19. Write a program that receive a file name and line of text as command line
arguments and write the text to the file.
20. Write a program that compares two files and returns 0 if they are equal and 1 if
they are not.
21. Write a program that appends one file at the end of another.
22. Write a program that reads a file containing integers and appends at its end the
sum of all the integers.
23. Write a program that reads all numbers from the input file values.dat and stores
the average of these numbers in an output file named as average.res.
24. Write a program which reads a line of characters. Each character entered from the
keyboard is tested to determine its case, and is then written to the data file in the
opposite case.
25. Write a program to illustrate passing structure pointers to functions.

24

You might also like