Pps Lab File Programs List
Pps Lab File Programs List
List of Programs
1. WAP that accepts the marks of 5 subjects and finds the sum and percentage marks obtained by the student.
2. WAP that calculates the Simple Interest and Compound Interest. The Principal, Amount, Rate of Interest and Time
are entered through the keyboard.
4. WAP that accepts the temperature in Centigrade and converts into Fahrenheit using the formula C/5=(F-32)/9.
6. WAP that checks whether the two numbers entered by the user are equal or not.
10.WAP that accepts marks of five subjects and finds percentage and prints grades according to the following
criteria:
80-90%-----------------Print ‘B’
60-80%-----------------Print ‘C’
11. WAP that takes two operands and one operator from the user, perform the operation, and prints the result by
using Switch statement.
20.WAP to convert binary number into decimal number and vice versa.
21. WAP that simply takes elements of the array from the user and finds the sum of these elements. 22.WAP that
inputs two arrays and saves sum of corresponding elements of these arrays in a third array and prints them.
25.WAP to sort the elements of the array in ascending order using Bubble Sort technique. Page 33 of 40
29.Define a structure data type TRAIN_INFO. The type contain 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:
a. List all the trains (sorted according to train number) that depart from a particular section.
b. List all the trains that depart from a particular station at a particular time.
c. List all he trains that depart from a particular station within the next one hour of a given time.
d. List all the trains between a pair of start station and end station.
31. WAP to compare the contents of two files and determine whether they are same or not.
32.WAP to check whether a given word exists in a file or not. If yes then find the number of times it occurs
1. WAP that accepts the marks of 5 subjects and finds the sum and
percentage marks obtained by the student.
#include <stdio.h>
int main()
{
float subject1, subject2, subject3, subject4, subject5, total_marks, percentage;
printf("Enter marks for subject 1: ");
scanf("%f", &subject1);
printf("Enter marks for subject 2: ");
scanf("%f", &subject2);
printf("Enter marks for subject 3: ");
scanf("%f", &subject3);
printf("Enter marks for subject 4: ");
scanf("%f", &subject4);
printf("Enter marks for subject 5: ");
scanf("%f", &subject5);
total_marks = subject1 + subject2 + subject3 + subject4 + subject5;
percentage = (total_marks / 500) * 100;
printf("\nTotal marks obtained: %.2f\n", total_marks);
printf("Percentage obtained: %.2f%%\n", percentage);
return 0;
}
2. WAP that calculates the Simple Interest and Compound Interest. The Principal, Amount, Rate of
Interest and Time are entered through the keyboard.
#include <stdio.h>
#include <math.h>
int main()
{
float principal, rate, time, simple_interest, compound_interest, amount;
printf("Enter Principal: ");
scanf("%f", &principal);
printf("Enter Rate of Interest (in percentage): ");
scanf("%f", &rate);
printf("Enter Time (in years): ");
scanf("%f", &time);
simple_interest = (principal * rate * time) / 100;
amount = principal * pow((1 + rate / 100), time);
compound_interest = amount - principal;
printf("\nSimple Interest: %.2f\n", simple_interest);
printf("Compound Interest: %.2f\n", compound_interest);
return 0;
}
2. WAP to calculate the area and circumference of a circle.
3. #include <stdio.h>
4. #define PI 3.14159
5. int main() {
6. double radius, area, circumference;
7. printf("Enter the radius of the circle: ");
8. scanf("%lf", &radius);
9. area = PI * radius * radius;
10. circumference = 2 * PI * radius;
11. printf("Area of the circle: %.2lf\n", area);
12. printf("Circumference of the circle: %.2lf\n", circumference);
13. return 0;
14. }
4. WAP that accepts the temperature in Centigrade and converts into Fahrenheit using the formula C/5=(F-32)/9.
1. #include<stdio.h>
2. int main()
3. {
4. float fahrenheit, celsius;
5. celsius = 24;
6. fahrenheit =( (celsius*9)/5)+32;
7. printf("\n\n Temperature in fahrenheit is: %f",fahrenheit);
8. return (0);
9. }
#include<stdio.h>
/*5. WAP that swaps values of two variables using a third variable. */
void main()
{
int a,b,temp;
printf("Enter a=");
scanf("%d",&a);
printf("Enter b=");
scanf("%d",&b);
temp=a;
a=b;
b=temp;
printf("\nAfter swapping");
printf("\na=%d",a);
printf("\nb=%d",b);
}
6. WAP that checks whether the two numbers entered by the user are equal or not.
#include<stdio.h>
/*WAP that checks whether the two numbers entered by the user are equal or not. */
void main()
{
int a,b;
printf("Enter a=");
scanf("%d",&a);
printf("Enter b=");
scanf("%d",&b);
if(a==b)
{
printf("\na and b are equal.");
}
else
{
printf("\na and b are not equal.");
}
}
7. WAP to find the greatest of three numbers.
#include<stdio.h>
/*WAP to find the greatest of three numbers. */
void main()
{
int a,b,c;
printf("Enter a=");
scanf("%d",&a);
printf("Enter b=");
scanf("%d",&b);
printf("Enter c=");
scanf("%d",&c);
if(a>b)
{
if(a>c)
{
printf("\n a is greatest.");
}
else
{
printf("\n c is greatest.");
}
}
else
{
if(b>c)
{
printf("\n b is greatest.");
}
else
{
printf("\n c is greatest.");
}
}
}
if(n%2==0)
{
printf("\n n is even number.");
}
else
{
printf("\n n is odd number.");
}
}
9. WAP that tells whether a given year is a leap year or not.
#include<stdio.h>
/* WAP that tells whether a given year is a leap year or not. */
void main()
{
int year;
printf("Enter a number=");
scanf("%d",&year);
if((year%4==0||year%400==0)&&year%100!=0)
{
printf("\nYear is leap year.");
}
else
{
printf("\nYear is not leap year.");
}
9. }
10. WAP 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‟
#include<stdio.h>
/*WAP that accepts the marks of 5 subjects and finds the sum and percentage marks obtained by the student.*/
void main()
{
int hindi, english, science,math,computer,sum ;
float per;
printf("Enter marks of Hindi=");
scanf("%d",&hindi);
printf("Enter marks of English=");
scanf("%d",&english);
printf("Enter marks of Science=");
scanf("%d",&science);
printf("Enter marks of Math=");
scanf("%d",&math);
printf("Enter marks of Computer=");
scanf("%d",&computer);
sum=hindi+english+science+math+computer;
printf("\nSum of marks=%d",sum);
per=(float)sum/5;
printf("\nPercentage of marks=%f",per);
if(per>=90&&per<=100)
{
printf("\nGrade A");
}
else if(per>=80&&per<90)
{
printf("\nGrade B");
}
else if(per>=60&&per<80)
{
printf("\nGrade C");
}
else if(per<60)
{
printf("\nGrade D");
}
}
11. WAP that takes two operands and one operator from the user, perform the operation, and prints the result by
using Switch statement.
#include<stdio.h>
void main()
{
int choice,a,b;
printf("Select your choice:\n");
printf("1- Add:\n");
printf("2- Sub:\n");
printf("3- Mul:\n");
printf("4- Div:\n");
printf("5- Mod:\n");
printf("Enter number a=");
scanf("%d",&a);
printf("Enter number b=");
scanf("%d",&b);
printf("Enter your choice=");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Add of a and b %d",(a+b));
break;
case 2:
printf("Sub of a and b %d",(a-b));
break;
case 3:
printf("Mul of a and b %d",(a*b));
break;
case 4:
printf("Div of a and b %d",(a/b));
break;
case 5:
printf("Mod of a and b %d",(a%b));
break;
default:
printf("Wronf choice.");
}
}
void main()
{ int n,r,rev=0,p=0;
printf("Enter binary number=");
scanf("%d",&n);
while(n>0)
{ r=n%10;
if(r!=0)
{ rev= rev+(int)pow(2,p);
}
n=n/10; p++;
}
printf("Decimal number=%d",rev);
}
21. WAP that simply takes elements of the array from the user and finds the sum of these elements.
#include<stdio.h>
int main()
{
//let's assume the maximum array size as 100.
//initialize sum as 0. Otherwise, it will take some garbage value.
int arr[100], size, i, sum = 0;
return 0;
}
22.WAP that inputs two arrays and saves sum of corresponding elements of these arrays in a third array and prints
them.
#include<stdio.h>
void main()
{
int i,ar1[10],ar2[10],sum[10];
printf("Enter first array:-\n");
for(i=0;i<=9;i++)
{
printf("ar1[%d]=",i);
scanf("%d",&ar1[i]);
}
printf("Enter second array:-\n");
for(i=0;i<=9;i++)
{
printf("ar2[%d]=",i);
scanf("%d",&ar2[i]);
}
for(i=0;i<=9;i++)
{
sum[i]=ar1[i]+ar2[i];
}
printf("Sum of arrays:-");
for(i=0;i<=9;i++)
{
printf("\nsum[%d]=%d",i,sum[i]);
}
25.WAP to sort the elements of the array in ascending order using Bubble Sort technique.
#include<stdio.h>
void main()
{ int i,j,ar[10],temp;
printf("Enter array:-\n");
for(i=0;i<=9;i++)
{ printf("ar[%d]=",i);
scanf("%d",&ar[i]); }
for(i=0;i<=9;i++)
{ for(j=0;j<=9-i;j++)
{ if(ar[j]>ar[j+1])
{ temp=ar[j];
ar[j]=ar[j+1];
ar[j+1]=temp; } } }
printf("Sorted array:-");
for(i=0;i<=9;i++)
{ printf("\n%d",ar[i]); }
}
28.WAP to implement strlen (), strcat (),strcpy () using the concept of Functions.
#include<stdio.h>
#include <string.h>
void main()
char st[20]={'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l','d', '\0'};
strcat(wd1,wd2);
char st2[20];
strcpy(st2,st1);
29. Define a structure data type TRAIN_INFO. The type contain 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:
a. List all the trains (sorted according to train number) that depart from a particular section.
b. List all the trains that depart from a particular station at a particular time.
c. List all he trains that depart from a particular station within the next one hour of a given time.
d. List all the trains between a pair of start station and end station.(Do it by yourself )
31. WAP to compare the contents of two files and determine whether they are same or not.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
// Driver code
int main()
{
// opening both file in read only mode
FILE *fp1 = fopen("file1.txt", "r");
FILE *fp2 = fopen("file2.txt", "r");
compareFiles(fp1, fp2);
int i;
char ch,str[40];
printf(“enter the string=”);
scanf(“%s”,&str);
// Take each character from this string to check
for (i = 0; str[i] != '\0'; i++) {
else
// Else increment the count of consonants
consonants++;
}