0% found this document useful (0 votes)
57 views19 pages

Pps Programs

The document contains 14 programs with their objectives and source code. The programs cover basics of C programming like input/output, arithmetic operations, if-else conditions, loops, functions etc. Various concepts demonstrated include calculating sum and percentage, simple and compound interest, area of circle, temperature conversion, swapping values, checking even/odd, leap year, grades etc.

Uploaded by

ayushivats509
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views19 pages

Pps Programs

The document contains 14 programs with their objectives and source code. The programs cover basics of C programming like input/output, arithmetic operations, if-else conditions, loops, functions etc. Various concepts demonstrated include calculating sum and percentage, simple and compound interest, area of circle, temperature conversion, swapping values, checking even/odd, leap year, grades etc.

Uploaded by

ayushivats509
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

1

PROGRAM 1:

OBJECTIVE:WRITE A PROGRAM THAT ACCEPTS MARKS OF FIVE SUBJECTS AND FINDS SUM AND PERCENTAGE
MARKS OBTAINED.

SOURCE CODE:

//program to print sum and percentage of marks of five subjects

#include<stdio.h>

#include<conio.h>

int main()

int m1,m2,m3,m4,m5,sum;

float p1=0.0,percentage=0.0;

printf("enter marks of 5 subjects");

scanf("%d %d %d %d %d",&m1,&m2,&m3,&m4,&m5);

sum=m1+m2+m3+m4+m5;

p1=(sum/500.0);

percentage=p1*100.0;

printf("the sum is %d \n",sum);

printf("the percentage is %f",percentage);

return 0;

INPUT:

enter marks of 5 subjects96 97 98 95 94

OUTPUT:

the sum is 480

the percentage is 96.000000

B4 G2
AYUSHI VATS
22AIML103
2

PROGRAM 2:

OBJECTIVE: WRITE A PROGRAM THAT CALCULATES THE SIMPLE INTEREST AND COMPOUND INTEREST.THE
PRINCIPLE,AMOUNT,RATE OF INTEREST ARE ENTERED THROUGH THE KEYBOARD.

SOURCE CODE:

//program to find simple and compound interest

#include<stdio.h>

#include<math.h>

int main()

int p,r,t,CI;

float SI,A,amt;

printf("enter principle rate and time");

scanf("%d %d %d",&p,&r,&t);

SI=p*r*t/100.0;

A=p*(1+r/100.0);

t=t*2;

amt=pow(A,t);

CI=amt-p;

printf("\n Simple Interest is %f",SI);

printf("\n Compound Interest is %d",CI);

return 0;

INPUT:

enter principle rate and time 100 5 1

OUTPUT:

Simple Interest is 5.000000

Compound Interest is 10925

B4 G2
AYUSHI VATS
22AIML103
3

PROGRAM 3:

OBJECTIVE: WRITE A PROGRAM TO PRINT THE AREA AND CIRCUMFERENCE OF CIRCLE.

SOURCE CODE:

//program to find area and circumference of a circle

#include<stdio.h>

#include<conio.h>

int main()

int r;

float area,circ;

printf("enter radius");

scanf("%d",&r);

circ=2*3.14*r;

area=3.14*r*r;

printf("\n area is %f",area);

printf("\n circumference is %f",circ);

return 0;

INPUT:

enter radius 7

OUTPUT:

area is 153.860001

circumference is 43.959999

B4 G2
AYUSHI VATS
22AIML103
4

PROGRAM 4:

OBJECTIVE: WRITE A PROGRAM THAT ACCEPTS THE TEMPRATURE IN CENTIGRADE AND CONVERTS IT INTO
FAHRENHEIT USINF FORMULA C/5=(F-32)/9.

SOURCE CODE:

//program to convert degree centigrade into Fahrenheit

#include<stdio.h>

#include<conio.h>

int main()

float t,t2,t3;

t3=0.0f;

printf("Enter temprature in degree celcius");

scanf("%f",&t);

t2=9.0*t/5.0;

t3=t2+32;

printf("\n temp in Fahrenheit is %f",t3);

return 0;

INPUT :

Enter temprature in degree celcius

OUTPUT:

temp in Fahrenheit is 176.000000

B4 G2
AYUSHI VATS
22AIML103
5

PROGRAM 5:

OBJECTIVE: WRITE A PROGRAM THAT SWAPS VALUE OF TWO VARIABLE USING A THIRD VARIABLE.

SOURCE CODE:

//program to swap value of two variables using a third variable

#include<stdio.h>

#include<conio.h>

int main()

int a,b,c;

printf("enter two numbers");

scanf("%d %d",&a,&b);

c=a;

a=b;

b=c;

printf("\n the variables are a=%d",a);

printf("b=%d",b);

return 0;

INPUT:

Enter two numbers 6 7

OUTPUT:

The variables are a=7 b=6

B4 G2
AYUSHI VATS
22AIML103
6

PROGRAM 6:

OBJECTIVE: WRITE A PROGRAM THAT CHECKS WHETHER THE TWO NUMBERS ENTERED BY THE USER ARE EQUAL
OR NOT.

SOURCE CODE:

//program to check whether numbers entered are equal or not

#include<stdio.h>

#include<conio.h>

int main()

int a,b;

printf("enter two numbers");

scanf("%d %d",&a,&b);

if(a==b)

printf("the numbers entered are equal");

else

printf("the numbers entered are not equal");

return 0;

INPUT:

enter two numbers4 6

OUTPUT:

the numbers entered are not equal

B4 G2
AYUSHI VATS
22AIML103
7

PROGRAM 7:

OBJECTIVE: WRITE A PROGRAM TO FIND THE GREATEST OF THREE NUMBERS.

SOURCE CODE:

//program to find the greatest of three numbers

#include<stdio.h>

#include<conio.h>

int main()

int a,b,c;

printf("enter three numbers");

scanf("%d %d %d",&a,&b,&c);

if(a>b&&a>c)

printf("%d is the largest number",a);

else if(b>a&&b>c)

printf("%d is the largest number",b);

else

printf("%d is the largest number",c);

return 0;

INPUT:

Enter three numbers 7 8 9

OUTPUT:

B4 G2
AYUSHI VATS
22AIML103
8

9 is the largest number

B4 G2
AYUSHI VATS
22AIML103
9

PROGRAM 8:

OBJECTIVE: WRITE A PROGRAM THAT FINDS WHETHER A GIVEN NUMBER IS EVEN OR ODD.

SOURCE CODE:

//program to find whether a given number is even or odd

#include<stdio.h>

#include<conio.h>

int main()

int a;

printf("enter a number");

scanf("%d",&a);

if(a%2==0)

printf("the given number is even");

else

printf("the given number is odd");

return 0;

INPUT:

enter a number67

OUTPUT:

The given number is odd

B4 G2
AYUSHI VATS
22AIML103
10

PROGRAM 9:

OBJECTIVE: WRITE A PROGRAM THAT TELLS WHETHER A GIVEN YEAR IS A LEAP YEAR OR NOT.

SOURCE CODE:

//program to check whether given year is leap year or not

#include<stdio.h>

#include<conio.h>

int main()

int a;

printf("enter an year");

scanf("%d",&a);

if(a%4==0)

printf("the year %d is a leap year",a);

else

printf("the year %d is not a leap year",a);

return 0;

INPUT:

enter an year2004

OUTPUT:

The year 2004 is a leap year

B4 G2
AYUSHI VATS
22AIML103
11

PROGRAM 10:

OBJECTIVE: WRITE A PROGRAM THAT ACCEPTS MARKS OF FIVE SUBJECTS AND FINDS PERCENTAGE AND POINTS
GRADE ACCORDING TO THE FOLLOWING CRITERIA:

BETWEEN 90-100%------PRINT ‘A’

BETWEEN 80-90%--------PRINT ‘B’

BETWEEN 60-80%--------PRINT ‘C’

BELOW 60%----------------PRINT ‘D’

SOURCE CODE:

//program to display grades of a student

#include<stdio.h>

#include<conio.h>

int main()

int m1,m2,m3,m4,m5,sum;

float per;

printf("enter marks of five subject");

scanf("%d %d %d %d %d",&m1,&m2,&m3,&m4,&m5);

sum=m1+m2+m3+m4+m5;

per=sum*100/500.0;

if(per<100&&per>90)

printf("A");

else if(per<90&&per>80)

printf("B");

else if(per<80&&per>60)

printf("C");

}
B4 G2
AYUSHI VATS
22AIML103
12

else

printf("D");

return 0;

INPUT:

enter marks of five subject 98 97 96 95 94

OUTPUT:

B4 G2
AYUSHI VATS
22AIML103
13

PROGRAM 11:

OBJECTIVE: WRITE A PROGRAM THAT TAKES TWO OPERANDS AND ONE OPERATOR FROM THE USRE,PERFORMS
THE OPERATION AND PRINTS RESULT OF ALL NUMBERS BY USING SWITCH STATEMENT.

SOURCE CODE:

//program to take two operand and one operator from the user and perform operation

#include<stdio.h>

#include<conio.h>

int main()

int n1,n2,o;

char op;

printf("Enter two numbers and one operand from +,-,*,/");

scanf("%d %d %c",&n1,&n2,&op);

switch(op)

case '+':

o=n1+n2;

printf("sum is =%d",o);

break;

case '-':

o=n1-n2;

printf("subtraction is =%d",o);

break;

case '*':

o=n1*n2;

printf("multiplication is =%d",o);

break;

case '/':

o=n1/n2;

printf("division is =%d",o);

break;
B4 G2
AYUSHI VATS
22AIML103
14

return 0;

INPUT:

Enter two numbers and one operand from +,-,*,/ 63/

OUTPUT:

Division is = 2

B4 G2
AYUSHI VATS
22AIML103
15

PROGRAM 12:

OBJECTIVE: WRITE A PROGRAM TO PRINT THE SUM OF ALL NUMBERS UPTO A GIVEN NUMBER.

SOURCE CODE:

//program to print sum of all numbers upto a given number

#include<stdio.h>

#include<conio.h>

int main()

int n,i,s=0;

printf("enter a number");

scanf("%d",&n);

for(i=1;i<=n;i++)

s=s+i;

printf("sum is=%d",s);

return 0;

INPUT:

Enter a number 6

OUTPUT:

Sum is =21

B4 G2
AYUSHI VATS
22AIML103
16

PROGRAM 13:

OBJECTIVE: WRITE A PROGRAM TO FIND FACTORIAL OF A GIVEN NUMBER.

SOURCE CODE:

//program to print factorial of a number

#include <stdio.h>

#include <conio.h>

int main()

int n,i,p=1;

printf("enter a number");

scanf("%d",&n);

for(i=1;i<=n;i++)

p=p*i;

printf("product is=%d",p);

return 0;

INPUT:

enter a number =5

OUTPUT:

Product is = 120

B4 G2
AYUSHI VATS
22AIML103
17

PROGRAM 14:

OBJECTIVE: WRITE A PROGRAM TO PRINT THE SUM OF EVEN AND ODD NUMBERS.

SOURCE CODE:

//program to print sum of even and odd numbers

#include <stdio.h>

#include <conio.h>

int main()

int n,s1=0,s2=0,i;

printf("enter a number");

scanf("%d",&n);

for(i=1;i<=n;i++)

if(i%2==0)

s1=s1+i;

else

s2=s2+i;

printf("sum of even numbers is=%d \n",s1);

printf("sum of odd numbers is=%d",s2);

return 0;

INPUT:

enter a number 9

OUTPUT:

sum of even numbers is= 20

B4 G2
AYUSHI VATS
22AIML103
18

sum of odd numbers is =25

PROGRAM 15:

OBJECTIVE: WRITE A PROGRAM TO PRINT FIBONACCI SERIES.

SOURCE CODE:

#include <stdio.h>

int main()

int n, i = 0, Next,n1 = 0, n2 = 1;

printf("\n Please Enter the Range Number: ");

scanf("%d",&n);

while(i<n)

if(i<= 1)

Next = i;

else

Next = n1 + n2;

n1 = n2;

n2 = Next;

printf("%d \t", Next);

i++;

return 0;

INPUT:

Please Enter the Range Number: 10

B4 G2
AYUSHI VATS
22AIML103
19

OUTPUT:

0 1 1 2 3 5 8 13 21 34

B4 G2
AYUSHI VATS
22AIML103

You might also like