Practical Activity Comp
Practical Activity Comp
Topic 9:
Fundamentals of input and output handling
Main ()
{
Float Fahrenheit, Celsius;
Gets ("enter value of Celsius");
Puts ("enter value of Celsius");
char address[200];
printf(" Enter the customer address ");
gets( address );
puts( address );
getch();
char billingmonth[200];
printf(" Enter the billingmonth ");
gets( billingmonth );
puts( billingmonth );
getch();
printf("Enter perunitrate");
scanf("%f",& perunitrate);
getch();
printf("Enter GST");
scanf("%f",& GST );
getch();
unitconsumed=presentreading-previousreading;
printf("%f unitconsumed",unitconsumed);
getch();
KECharges=perunitrate*unitconsumed;
printf("%f KECharges",KECharges);
getch();
totalamount= KECharges+ElectricityDuty+GST;
printf("%f totalamount",totalamount);
getch();
}
6. To find the interest in an amount:
Algorithm :
Step 1: start
Step 2: input number p,r,t
Step 3: calculate interest using formula si=(p*r*t)/100
Step 4: print simple interest si
Step 5: end
Coding :
#include<stdio.h>
#include<conio.h>
main()
{
int p,r,t,iint;
p=2;
r=4;
t=6;
int i=(p*r*t)/100;
printf=("%d int",int);
getch()
}
7. To find the sum, product, and average of five given
numbers
Algorithm:
Step 1: start
Step 2: take five numbers suppose a,b,c,d and e
Step 3: declare variable sum,prod and avg
Step 4: sum=a+b+c+d+e
Step 5: prod=a*b*c*d*e
Step 6: avg=sum/5
Step 7: display result of sum,prod and avg
Step 8: end
Coding :
#include<stdio.h>
#include<conio.h>
main()
{
int add,mul,avg;
int a=40 ,b=20 ;
add = a+b;
printf("Addition of a, b is : %d\n", add);
mul = a*b;
printf("Multiplication of a, b is : %d\n", mul);
avg=sum/5;
printf("average of a,b is :%d/n",avg);
getch();
}
8. To find acceleration of a moving object with given
mass and the force applied:
Algorithm :
Step 1: start
Step 2: input numbers mass and force
Step 3: set acceleration to force/mass
Step 4: output acceleration
Step 5: end
Coding:
#include<stdio.h>
#include<conio.h>
main()
{
int m,f,a,acc;
f=50;
m=10;
a=f/m;
printf("%d acc",acc);
getch();
}