CODING EXERCISES IN C PROGRAMMING LANGUAGE.


Note : Here in all the programs we assume that input is given by the user.


  1. Write a program to find sum of two numbers.
  2. Write a program to find area and circumference of circle.
  3. Write a program to find the simple interest.
  4. Write a program to convert temperature from degree centigrade to fahrenheit.
  5. Write a program to calculate sum of 5 subjects and find percentage.
  6. Write a program to show swap of two numbers without using third variable.
  7. Write a program to reverse a given number.
  8. Write a program to find gross salary.
  9. Write a program to print a table of any number.
  10. Write a program to find greatest in 3 numbers.
  11. Write a program to show the use of conditional operator.
  12. Write a program to find that entered year is leap year or not.
  13. Write a program to find whether given number is even or odd.
  14. Write a program to shift inputed data by two bits to the left.
  15. Write a program to use switch statement. Display Monday to Sunday.
  16. Write a program to display arithmetic operator using switch case.
  17. Write a program to display first 10 natural numbers and their sum.
  18. Write a program to print different stars Sequencel (like right angled triangle, Left sided right angled triangle and An equilateral triangle).
  19. Write a program to print fibonacci series upto 100.
  20. Write a program to find the factorial of a given number.
  21. Write a program to find whether a given number is prime or not.
  22. Write a program to display sum of series 1 + 1/2 + 1/3....+ 1/n.
  23. Write a program to display series and find sum of 1 + 3 + 5 .... + n.
  24. Write a program to use bitwise AND operator between the two integers.
  25. Write a program to add two numbers using pointers.
  26. Write a program to show sum of 10 elements of an array and show their average.
  27. Write a program to find the maximum no. in an array.
  28. Write a program to display a matrix.
  29. Write a program to find sum of two matrices.
  30. Write a program to find substraction of two matrices.
  31. Write a program to find multiplication of two matrices.
  32. Write a program to find transpose of a matrix.
  33. Write a program to find the maximum number in array using pointer.
  34. Write a program to find square of a number using functions.
  35. Write a program to swap two numbers using functions.
  36. Write a program to show table of numbers using functions.
  37. Write a program to show call by value.
  38. Write a program to show call by reference.
  39. Write a program to find largest of two numbers using funcitons.
  40. Write a program to find factorial of a number using recursion.
  41. Write a program to find whether a string is palindrome or not.
  42. Write a program to show file operations.
  43. Write a program to merge one dimensional array - excluding the repeating element.
  44. Write a program to find the number of occurences of vowel, consonants, words, spacs and special characters in the given statement.
  45. Write a program to create enumerated data type for 12 months and display their values in integer constants.
  46. Write a program to Evaluate the equation y = xn where, n is a non-negative integer.
  47. Write a program to print the multiplication table from 1*1 to 12*10.
  48. Write a program which uses a "for" loop to print the powers of 2 table for the power 0 to 20, both positive and negative.
  49. A class of "n" students take an annual examination in "m" subjects. Write a program to read the marks obtained by each student in various subjects and to compute and print the total marks obtained by each of them.
  50. Write a program to illustrate the use of break statement.
  51. Write a program to evaluate the series 1/(1-x) = 1 + x + x^2 + x^3 + ... + x^n.
  52. Write a program to illustrate the use of continue statement.
  53. Write a program to print binomial cofficient table.
  54. Write a program to draw a histogram.
  55. Write a program that calculate the minimal cost problem.
  56. Write a program for plotting of two functions y1 = exp(-ax); y2 = exp(-ax^2/2).
  57. Write a program using a single subscribed variable to evaluate the following expressions:

    Total = the values of x1, x2... are read from the terminal.

  58. Given below is the list of marks obtained by a class of 50 students in an annual examination 43 65 51 27 79 11 56 61 82 09 25 36 07 49 55 63 74 81 49 37 40 49 16 75 87 91 33 24 58 78 65 56 76 67 45 54 36 63 12 21 73 49 51 19 39 49 68 93 85 59. Write a program to count the number of students belonging to each of the of following groups of marks: 0-9, 10-19, 20-29, ... , 100.
  59. Write a program for sorting the elements of an array in descending order.
  60. Write a program for finding the largest number in an array.
  61. Write a program for removing the duplicate element in an array.
  62. Write a program for finding the desired smallest element in an array.
  63. Write a program to sort a list of numbers and determine median.
  64. Write a program to calculate standard deviation.
  65. Write a program to evaluate responses to a multiple choice test.
  66. Write a program for production and sales analysis.
  67. Write a program to read a series of words from a terminal using scanf function.
  68. Write a program to read a line of text from terminal.
  69. Write a program to copy one string into another and count the numeber of characters copied.
  70. Write a program for printing of the alphabet set in decimal and character form.
  71. Write a program to concatenation of strings.
  72. Write a program for illustration of string handling function.
  73. Write a program that would sort a list of names in alphabetical order.
  74. Write a program for counting of characters, words and lines in a text.
  75. Write a program to alphabetize a customer list.
  76. Write a program for functions with no arguments and no return values.
  77. Write a program for functions with arguments but no return values.
  78. Write a program for functions with arguments and return values.
  79. Write a function power that computes x raised to the power of y for integers x and y returns double-type value.
  80. Write a program to show how user-defined function is called.
  81. Write a program to define user-defined function. Call them at different places.
  82. Write a program to show how similiar variable names can be used in different functions.
  83. Write a program to show the effect of global variables on different funcitons.
  84. Write a program to display message using user-defined functions.
  85. Write a program to return more than one value from user defined function.
  86. Write a program to pass arguments to user-defined by value and by reference.
  87. Write a program to return only absolute value like abs() function.
  88. Write a program to calculate square and cube of an entered number. Use function as an argument.
  89. Write a program to assign return value of a function to another variable.
  90. Write a program to perform addition and substraction of numbers with return value of function.
  91. Write a program to perform multiplication and division of numbers with return value of function.
  92. Write a program to use (++) operator with return value of fucntion.
  93. Write a program to use mod(%) with function.
  94. Write a program to evaluate the equation s = sqr( a() + b() ) using function.
  95. Write a program to call user-defined function through if statement.
  96. Write a program to call user-defined function through switch() statement.
  97. Write a program to call function through the for loop.

State Whether the following statements are true or false.

  1. Every line in a C program should end with a semicolon.
  2. In C language lowercase letters are significant.
  3. Every C programs ends with an END word.
  4. main() is where the program begins it's execution.
  5. A line in a program may have more than one statement.
  6. A printf statement can generate only one line of output.
  7. The closing brace of the main() in a program is the logical end of the program.
  8. The purpose of the header file such as stdio.h is to store the source code of a program.
  9. Comments cause the computer to print the text enclosed between /* and */ when executed.
  10. Syntax errors will be detected by the compiler.
  11. Every C program must have at least one user-defined function.
  12. Declarations section contains instructions to the computer.
  13. Use of comments reduces the speed of execution of program.
  14. Comments serve as internal documentation for programmers.
  15. A comment can be inserted in the middele of a statement.
  16. In C, we can have comments inside comments.
  17. Any valid printable ASCII characeter can be used in an identifier.
  18. All variables must be given a type when they are declared.
  19. Declarations can appear anywhere in a program.
  20. ANSI C treats the variables name and Name to be same.
  21. The underscore can be used anywhere in an identifier.
  22. The keyword void is a data type in C.
  23. Floating point constants, by default, denote float type values.
  24. Like variables, constants have a type.
  25. Character constants are coded using double quotes.
  26. Initialization is the process of assigning a value to a variable at the time of declaration.
  27. All static variables are automatically initialized to zero.
  28. The scanf function can be used to read only one value at a time.
  29. All the arithmetic operator have the same level of precedence.
  30. The modulus operator % can be used only with integers.
  31. The operators <=, >= and != all enjoy the same level of priority.
  32. During modulo division, the sign of the result is positive, if both the operands of the same sign.
  33. In C, if a data item is zero, it is considered false.
  34. The expression !(x<=y) is same as the expression x>y.
  35. A unary expression consists of only one operand with no operators.
  36. Associativity is used to decide which of several different expressions is evaluated first.
  37. An expression statement is terminated with a period.
  38. During the evaluation of mixed expressions, an implicit cast is generated automatically.
  39. An explicit cast can be used to change the expression.
  40. Paranthesis can be used to change the order of evaluation expressions.