Search This Blog

Sep 23, 2013

C program to input four numbers and print percentages of each numbers on their sum.

/* write a program to input four numbers and print percentages of each numbers on their sum. */
#include<conio.h>
#include<stdio.h>
void main()
{
float a,b,c,d,e,pa,pb,pc,pd;
clrscr();
printf("Enter no a: \nEnter no b:\nEnter no c:\nEnter no d:");
scanf("%f%f%f%f",&a,&b,&c,&d);
e=a+b+c+d,pa=a/e*100,pb=b/e*100,pc=c/e*100,pd=d/e*100;
printf("Sum of 4 Nos= %.2fm\nPercentage of a= %.2f\nPercentage of b= %.2f\nPercentage of c= %.2f\nPercentage of d= %.2f",e,pa,pb,pc,pd);
getch();
}

No comments:

Post a Comment