KCS151/KCS251 PPS Lab Exercise Program: 05
KCS151P/KCS251P
LAB 1
LAB 2
LAB 3
Write a program to print the entire prime no between 1 and 300.
Write a program to print out all the Armstrong numbers between 100 and 500.
Write a program to draw the following figures:
3 2 1
2 1
1
*
**
***
Write a program to receive a five-digit no and display as like 24689:
2
4
6
8
9
LAB 4
Write a function that returns the sum of all the odd digits of a given positive no entered through the keyboard.
Write a program to print the area of the rectangle using function & return its value to the main function.
Write a program to calculate the factorial for the given number using a function.
Write a program to find the sum of the Fibonacci series using a function.
Write factorial function & use the function to find the sum of series S = 1! + 2! + … + n!
LAB 5
Write a program to find the factorial of the given number using recursion.
Write a program to find the sum of digits of a 5 digit number using recursion.
Write a program to calculate the GCD of given numbers using recursion.
Write a program to convert a decimal number into a binary number.
Write a program to convert a binary number into a decimal number.
LAB 6
Write a program to delete duplicate element in a list of 10 elements & display it on screen.
Write a program to merge two sorted arrays & no element is repeated during merging.
Write a program to evaluate the addition of diagonal elements of two square matrixes.
Write a program to find the transpose of a given matrix & check whether it is symmetric or not.
Write a program to print the multiplication of two N*N (Square) matrix.
LAB 7
Write a program in C to check whether the given string is a palindrome or not.
Write a program to sort the array of characters (String) in alphabetical order like STRING in GINRST.
Write a program to remove all the blank space from the string & print it, also count the no of characters.
Write a program to store the following string “zero”, “one”, … “five”.
Print the no in words, given in figure as 3205.
LAB 8
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.
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.
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.
LAB 9
Write a C program to copy & count the character content of one file, says a.txt to another file b.txt.
Write a program to take 10 integers from a file and write the square of these integers in another file.
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.
Write a program to print all the prime numbers, between 1 to 100 in file prime.txt.
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.
LAB 10
Write a program to find the largest no among 20 integers array using dynamic memory allocation.
Using Dynamic Memory Allocation, Write a program to find the transpose of the given matrix.
Write a program to find the factorial of the given number using the command line argument.
Write a program to find the sum of digits of a 5 digit number using the command line argument.
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
/*
File: Prgrm05.c
Author: Aditya Saini
Date: Jan 15, 2021
Description: Program to check eligibility.
*/
#include
int main (void)
{
int phy_marks, chem_marks, math_marks;
//Input marks.
printf ("Input Marks:\n");
printf ("Physics: ");
scanf ("%d", &phy_marks);
printf ("Chemistry: ");
scanf ("%d", &chem_marks);
printf ("Mathematics: ");
scanf ("%d", &math_marks);
//Eligibility check
printf ("(a) Marks of physics > 40\t\t\t: ");
if (phy_marks > 40)
printf ("Pass\n");
else
printf ("Fail\n");
printf ("(b) Marks of chemistry > 50\t\t\t: ");
if (chem_marks > 50)
printf ("Pass\n");
else
printf ("Fail\n");
printf ("(c) Marks of math's > 60\t\t\t: ");
if (math_marks > 60)
printf ("Pass\n");
else
printf ("Fail\n");
printf ("(d) Total of physics & math's marks > 150\t: ");
if ((phy_marks + math_marks) > 150)
printf ("Pass\n");
else
printf ("Fail\n");
printf ("or\n(e) Total of three subjects marks > 200\t: ");
if ((phy_marks + chem_marks + math_marks) > 200)
printf ("Pass\n");
else
printf ("Fail\n");
//Print result
printf ("Eligibility: ");
if (phy_marks > 40 && chem_marks > 50 && math_marks > 60 &&
((phy_marks + math_marks) > 150 || (phy_marks + chem_marks + math_marks) > 200))
printf ("Eligible");
else
printf ("Not Eligible");
return 0;
};
Try it yourself
Sample Input and Output
Stdin Inputs:
78 49 82
Sample Result:
Input Marks:
Physics: 78
Chemistry: 49
Mathematics: 82
(a) Marks of physics > 40 : Pass
(b) Marks of chemistry > 50 : Fail
(c) Marks of math’s > 60 : Pass
(d) Total of physics & math’s marks > 150 : Pass
or
(e) Total of three subjects marks > 200 : Pass
Eligibility: Not Eligible