Monday 6 August 2012

Loop control structure008


Input five number and find the sum and average.

#include <stdio.h>
#include <conio.h>


void main ( )
{
        int           co = 1, no, avg, s = 0;
        clrscr ( );
         
        while ( co <= 5 )
        {                     
                       printf ("\n\t Enter a number.....:"); scanf ("%d",&no);
                       s = s + no;
                       co ++;
        }
        avg = s / 5;
        printf ("\n\t SUM = %d", s);
        printf ("\n\t AVARAGE = %d", avg);
        getch ( );
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...