KCS151/KCS251 PPS Lab Exercise C Programs

KCS151/KCS251 Programming for Problem Solving – Using C

Lab Exercise

Click on any of the programs below to see the code…

  1. Write a program to calculate the area of the triangle using the formula at=√s(s-a)(s-b)(s-c).
  2. The basic salary of an employee is input through the keyboard. The DA is 25% of the basic salary while the HRA is 15% of the basic salary. Provident Fund is deducted at the rate of 10% of the gross salary (BS+DA+HRA).
    Program to calculate the Net Salary.
  3. Write a program to determine the roots of a quadratic equation.
  4. Write a program to find the largest of three numbers using nested if-else.
  5. Write a program to receive marks of physics, chemistry & maths from user & check its eligibility for the course if
    a) Marks of physics > 40
    b) Marks of chemistry > 50
    c) Marks of math’s > 60
    d) Total of physics & math’s marks > 150
         or
    e) Total of three subjects marks > 200
  6. Write a program to find the value of y for a particular value of n. The a, x, b, n is input by user
    if n = 1 y = ax % b
    if n = 2 y = ax2 + b2
    if n = 3 y = a – bx
    if n = 4 y = a + x/b
  7. Write a program to construct a Fibonacci series up to n terms.
  8. Write a program to find whether the number is Armstrong’s number.
  9. Write a program to generate sum of series 1! + 2! + 3! + … + n!
  10. Write a program to find the sum of the following series
    1 – X1/1! + X2/2! – … Xn/n!
  11. Write a program to print the entire prime no between 1 and 300.
  12. Write a program to print out all the Armstrong numbers between 100 and 500.
  13. Write a program to draw the following figures:
    3 2 1
    2 1
    1  *
     **
    ***
  14. Write a program to receive a five-digit no and display as like 24689:
    2

    4
    6
    8
    9
  15. Write a function that returns the sum of all the odd digits of a given positive no entered through the keyboard.
  16. Write a program to print the area of the rectangle using function & return its value to the main function.
  17. Write a program to calculate the factorial for the given number using a function.
  18. Write a program to find the sum of the Fibonacci series using a function.
  19. Write factorial function & use the function to find the sum of series S = 1! + 2! + … + n!
  20. Write a program to find the factorial of the given number using recursion.
  21. Write a program to find the sum of digits of a 5 digit number using recursion.
  22. Write a program to calculate the GCD of given numbers using recursion.
  23. Write a program to convert a decimal number into a binary number.
  24. Write a program to convert a binary number into a decimal number.
  25. Write a program to delete duplicate element in a list of 10 elements & display it on screen.
  26. Write a program to merge two sorted arrays & no element is repeated during merging.
  27. Write a program to evaluate the addition of diagonal elements of two square matrixes.
  28. Write a program to find the transpose of a given matrix & check whether it is symmetric or not.
  29. Write a program to print the multiplication of two N*N (Square) matrix.
  30. Write a program in C to check whether the given string is a palindrome or not.
  31. Write a program to sort the array of characters (String) in alphabetical order like STRING in GINRST.
  32. Write a program to remove all the blank space from the string & print it, also count the no of characters.
  33. Write a program to store the following string “zero”, “one”, … “five”.
    Print the no in words, given in figure as 3205.
  34. Write a program to compare two given dates. To store a date uses a structure that contains three members namely day, month, and year. If the dates are equal then display message equal otherwise unequal.
  35. Define a structure that can describe a hotel. It should have the member that includes the name, address, grade, room charge, and the number of rooms.
    Write a function to print out the hotel of given grade in order of room charges.
  36. Define a structure called cricket with player name, team name, batting average, for 55 players & 5 teams. Print team-wise list contains names of players with their batting average.
  37. Write a C program to copy & count the character content of one file, says a.txt to another file b.txt.
  38. Write a program to take 10 integers from a file and write the square of these integers in another file.
  39. Write a program to read numbers from a file and then write all ‘odd’ numbers to file ODD.txt & all ‘even’ to file EVEN.txt.
  40. Write a program to print all the prime numbers, between 1 to 100 in file prime.txt.
  41. Write the following C program using pointer:
    a) To sort the list of numbers through the pointer.

    b) To reverse the string through the pointer.
  42. Write a program to find the largest no among 20 integers array using dynamic memory allocation.
  43. Using Dynamic Memory Allocation, Write a program to find the transpose of the given matrix.
  44. Write a program to find the factorial of the given number using the command line argument.
  45. Write a program to find the sum of digits of a 5 digit number using the command line argument.

More C Programs

  1. Write a program that accepts the marks of 5 subjects and finds the sum and percentage of marks obtained by the student.
  2. Write a program that calculates the Simple Interest and Compound Interest. The Principal Amount, Rate of Interest, and Time are entered through the keyboard.
  3. Write a program to calculate the area and circumference of a circle.
  4. Write a program that accepts the temperature in Centigrade and converts it into Fahrenheit using the formula C / 5 = (F – 32) / 9.
  5. Write a program that swaps the values of two variables using a third variable.
  6. Write a program that checks whether the two numbers entered by the user are equal or not.
  7. Write a program to find the greatest of three numbers.
  8. Write a program that finds whether a given number is even or odd.
  9. Write a program that tells whether a given year is a leap year or not.
  10. Write a program that accepts marks of five subjects and finds percentage and prints grades according to the following criteria:
    Between
    90-100%—————————Print ‘A’
    80-90%—————————–Print ‘B’
    60-80%—————————–Print ‘C’
    Below 60%————————Print ‘D’.
  11. Write a program that takes two operands and one operator from the user and performs the operation and prints the result by using the Switch statement.
  12. Write a program to print the sum of all numbers up to a given number.
  13. Write a program to find the factorial of a given number.
  14. Write a program to print the sum of even and odd numbers from 1 to N numbers.
  15. Write a program to print the Fibonacci series.
  16. Write a program to check whether the entered number is prime or not.
  17. Write a program to find the sum of digits of the entered number.
  18. Write a program to find the reverse of a number.
  19. Write a program to print Armstrong numbers from 1 to 1000.
  20. Write a program to convert the binary number into a decimal number and vice versa.
  21. Write a program that simply takes elements of the array from the user and finds the sum of these elements.
  22. Write a program that inputs two arrays and saves the sum of corresponding elements of these arrays in a third array and prints them.
  23. Write a program to find the minimum and maximum elements of the array.
  24. Write a program to search an element in an array using Linear Search.
  25. Write a program to sort the elements of the array in ascending order using the Bubble Sort technique.
  26. Write a program to add and multiply two matrices.
  27. Write a program that finds the sum of diagonal elements of a m x n matrix.
  28. Write a program to implement strlen ( ), strcat ( ), strcpy ( ) using the concept of Functions.
  29. Define a structure data type TRAIN_INFO. The type contains Train No.: integer type, Train name: string, Departure Time: aggregate type TIME, Arrival Time: aggregate type TIME, Start station: string, End station: string. The structure type TIME contains two integer members: hour and minute. Maintain a train timetable and implement the following operations:
    (i) List all the trains (sorted according to train number) that depart from a particular station.
    (ii) List all the trains that depart from a particular station at a particular time.
    (iii) List all the trains that depart from a particular station within the next one hour of a given time.
    (iv) List all the trains between a pair of start station and end station.
  30. Write a program to swap two elements using the concept of pointers.
  31. Write a program to compare the contents of two files and determine whether they are the same or not.
  32. Write a program to check whether a given word exists in a file or not. If yes then find the number of times it occurs.
Please Share:
Facebook
Twitter
WhatsApp
Telegram
LinkedIn
Pinterest
Reddit
Tumblr
Email
Print

Leave a Comment

Your email address will not be published.

Scroll to Top