You are on page 1of 10

ASSIGNMENT NO-2

NIT HAMIRPUR

BATCH-CSE
PERSONNEL
DETAILS
NAME- ADITYA KUMAR MEENA
COURSE- CSE (Btech ,4 year)
SECTION- E2
ROLL NO – 195107

TOPIC- PRESENTATION FOR DEMONSTRATING


ALGORITHMS
Question-1: Find the average of
two numbers

a) Algorithm

#include<stdio.h>
#include<conio.h>
int main()
{
float a,b,avg;
printf("enter the first number");
scanf("%f",&a);
printf("enter the second number");
scanf("%f",&b);
avg=(a+b)/2;
printf("the average is %f",avg);
getch();
}
b) Pseudo Code

1- Start

2- Input a,b,avg

3- Compute avg = (a+b)/2

4- Output avg

5- Stop
c) Flow Chart

INPUT
START a,b,avg

OUTPU avg=(a+b)/
T avg 2

STOP
VARIABLES USED- a , b , avg

DATA TYPES- int , float

CONSTANT- 2
QUESTION- 2: TO FIND THE AREA OF
TRAPEZIUM

a) Algorithm

#include<stdio.h>
#include<conio.h>
int main()
{
float a,b,c,h;
printf("enter the parallel sides lengths");
scanf("%f%f",&a,&b);
printf("enter the height of trapezium");
scanf("%f",&h);
c=((a+b)*h)/2;
printf("the area of trapezium is %f",c);
getch();
}
b) PSEUDO CODE

1- Start

2- Input a , b , c , h

3- Compute c= ((a+b)*h)/2

4- Output c

5- Stop
C) FLOW CHART

INPUT a
,b,h,
START
c

C=
OUTPU
((a+b)*h)/2
Tc

STOP
VARIABLES USED- a , b , c ,
h

CONSTANTS- 2

DATA TYPES- int , float

You might also like