Lab File For PPS

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

LAB FILE

Programming for problem solving (BCS 151)

Bachelor of Technology
In
Computer Science & Engineering

(B.Tech 1st Year 1st Semester)

GREATER NOIDA COLLAGE, GREATER NOIDA


Affiliated to

Dr. APJ Abdul Kalam Technical University

Submitted to : Submitted by :
Ms. Deepshiksha Sharma Harpal Singh Lodhi
(Assistant Professor) B.Tech CSE (1st Sem)
Department of CSE Section A G-1
INDEX
S.N0. Activity/Programs Page No. Date Signature
PROGRAM NO. 1
Write a program that accepts the marks of 5 subjects and find the sum
and percentage marks obtained by the students.

#include<stdio.h>
int main()
{
int s1,s2,s3,s4,s5,sum;
float perc;

//Accept marks for 5 subjects max marks 100 for each subject
printf("Enter marks for 5 subjects: \n");
scanf("%d %d %d %d %d", &s1,&s2,&s3,&s4,&s5);

//Calculate sum of marks obtained


sum=s1+s2+s3+s4+s5;

//Calculate percentage of marks obtained


perc=(float)sum/5.0;

//Display sum and percentage of marks obtained


printf("\nSum of marks: %d",sum);
printf("\nPercentage of marks obtained: %.2f\n",perc);

return 0;
}
Output
PROGRAM NO. 2
Write a program that calculate the Simple Interest and Compound
Interest. The Principle, Amount, Rate of interest and Time are entered
through the keyboard.
#include<stdio.h>
#include<math.h>
int main()
{
float p,r,t,si,ci;
int n;

/*Accept input for principal, rate of interest,


time and number of times compounded*/

printf("Enter the Principal Amount:");


scanf("%f",&p);
printf("Enter the rate of interest:");
scanf("%f",&r);
printf("Enter the time period:");
scanf("%f",&t);
printf("Enter the no of times the interest is compounded in a year:");
scanf("%f",&n);

//Calculate Simple Interest


si=(p*r*t)/100.0;
printf("\nSimple Intrest=%.2f",si);

//Calculate Compound Intrest


ci=p*pow(1+(r/(100.0*n)),n*t);
printf("\nCompound Intrest=%.2f",ci);
return 0;
}
Output
PROGRAM NO. 3
Write a program to calculate the area and circumference of a circle.

#include<stdio.h>
int main()
{
float r,ar,cir;
float pi=3.141;
//Accept input for Circle
printf("Enter the radius of the circle:");
scanf("%f",&r);

//Calculate area and Circumference of circle


ar=(pi*r*r);
cir=(2*pi*r);

//Display area and circumference


printf("\nArea of Circle=%.2f",ar);
printf("\nCircumference of Circle=%.2f",cir);

return 0;
}
Output

You might also like