//Program to find out the average of three numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
float d;
clrscr();
printf("Enter Three numbers ");
scanf("%d%d%d",&a,&b,&c);
d=(a+b+c)/3;
printf("Average is = %f",d);
getch();
return 0;
}
To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
float d;
clrscr();
printf("Enter Three numbers ");
scanf("%d%d%d",&a,&b,&c);
d=(a+b+c)/3;
printf("Average is = %f",d);
getch();
return 0;
}
To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.
#include
ReplyDeleteint main()
{
int a,b,c,d,e,sum;
float avg;
printf("enter a: ");
scanf("%d", &a);
printf("enter b: ");
scanf("%d", &b);
printf("enter c: ");
scanf("%d", &c);
printf("enter d: ");
scanf("%d", &d);
printf("enter e: ");
scanf("%d", &e);
sum= a+b+c+d+e;
printf("Sum is: %d\n", sum);
avg=sum/5;
printf("Avg is: %f\n", avg);
return 0;
}
It's very good and easily explained.
DeleteResult of arithmetic operation between integers can't be float. So this programme will not work perfectly incase your average is in float.
ReplyDeleteThe solution is that declare every variable (i.e. a b c and d as float in above programme ) as float if your result can be in float.
Khanvai...
Yes right
DeleteIt's very good and very easily explained
ReplyDelete