Advertisement
Shailrshah

Cricketer's Database

Apr 19th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include <stdio.h>
  2. struct crickerters
  3. {
  4.     char name[20];
  5.     int matches;
  6.     long int score;
  7. }c[5];
  8. int main()
  9. {  
  10.     int i;
  11.     for (i=0;i<5;i++)
  12.     {
  13.         int a;
  14.         long int b;
  15.         printf("Enter the Name:  ");
  16.         scanf("%s",c[i].name);
  17.         printf("Enter the no. of matches played: ");
  18.         scanf("%d",&a);
  19.         c[i].matches = a;
  20.         printf("Enter the total runs scored: ");
  21.         scanf("%ld",&b);
  22.         c[i].score = b;
  23.     }
  24.     for(i=0;i<5; i++)
  25.     {
  26.         printf("\n\n%s\t\t%d\t%ld\n",c[i].name,c[i].matches,c[i].score);
  27.     }
  28. }
  29. //Output
  30. //Enter the Name:  Sachin
  31. //Enter the no. of matches played: 100
  32. //Enter the total runs scored: 10000
  33. //Enter the Name:  Gayle
  34. //Enter the no. of matches played: 50
  35. //Enter the total runs scored: 1000
  36. //Enter the Name:  Pointing
  37. //Enter the no. of matches played: 25
  38. //Enter the total runs scored: 900
  39. //Enter the Name:  Akhtar
  40. //Enter the no. of matches played: 76
  41. //Enter the total runs scored: 340
  42. //Enter the Name:  Sangakara
  43. //Enter the no. of matches played: 97
  44. //Enter the total runs scored: 9655
  45.  
  46.  
  47. //Sachin          100     10000
  48.  
  49.  
  50. //Gayle           50      1000
  51.  
  52.  
  53. //Pointing                25      900
  54.  
  55.  
  56. //Akhtar          76      340
  57.  
  58.  
  59. //Sangakara               97      9655
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement