I Wrote a program in which you enter the number of games played and number of games won in a sport (User Enters Number).
Im trying to get the winning percentage to output aswell.
How do I Divide Numbers in C? When I try, i get 0.0000
Code:#include <stdio.h> #include "genlib.h" #include "simpio.h" #include "strlib.h" int main() { int p1,w1,p2,w2,p3,w3,p4,w4,percent1,percent2,percent3,percent4; printf("Enter games played for League1: "); p1=GetInteger(); printf("Enter games won for League1: "); w1=GetInteger(); printf("\nEnter games played for League2: "); p2=GetInteger(); printf("Enter games won for League2: "); w2=GetInteger(); printf("\nEnter games played for League3: "); p3=GetInteger(); printf("Enter games won for League3: "); w3=GetInteger(); printf("\nEnter games played for League4: "); p4=GetInteger(); printf("Enter games won for League4:"); w4=GetInteger(); percent1=(w1/p1)*100; percent2=(w2/p2)*100; percent3=(w3/p3)*100; percent4=(w4/p4)*100; printf("Name"); printf(" Games Played"); printf(" Games Won"); printf(" Winning Percent"); printf("\n-------"); printf(" -------------"); printf(" ----------"); printf(" -------------\n"); printf("\nLeague1"); printf(" %d",p1); printf(" %d",w1); printf(" %f",percent1); printf("\nLeague2"); printf(" %d",p2); printf(" %d",w2); printf(" %f",percent2); printf("\nLeauge3"); printf(" %d",p3); printf(" %d",w3); printf(" %f",percent3); printf("\nLeauge4"); printf(" %d",p4); printf(" %d",w4); printf(" %f\n",percent4); }



LinkBack URL
About LinkBacks


