Search This Blog

Friday, October 7, 2011

Write a program to find avarege of Five numbers until the user wants to quit

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  void main()
   4:  {
   5:  int i;
   6:  float x,sum;
   7:  char q;
   8:  do
   9:  {
  10:  sum=0.0;
  11:  printf("Enter the five num:\n");
  12:  i=0;
  13:  while(i<5)
  14:  {
  15:  scanf("%f",&x);
  16:  sum+=x;
  17:  i++;
  18:  }
  19:  printf("sum=%f\n",sum);
  20:  printf("Type 'q' to quit:");
  21:  q=getche();
  22:  }while(q!='q'&&q!='Q');
  23:  getch();
  24:  }

No comments:

Post a Comment