Tuesday, 22 November 2016

Write a C++ program that input 5 values from user and stores them in array and display sum and average of these values.



        
        #include <iostream.h>
        #include <conio.h>
        int main ()

        {
           int num[5] , i , sum = 0 ;
           float average = 0.0 ;

           for (i = 0; i 5; i++)
           {
                cout<< "Enter  number: " ;
                cin>> num[i];
                sum = sum + num[i];
           }
           
           average =  sum / 5.0;
           cout<< "Sum is:  "<< sum;
           cout<< "Average  is:  "<< average;

          return 0;
           }

No comments:

Post a Comment

If you have any doubt please let me know

Methods in JAVA Language

 In general, a way may be thanks to perform some task. Similarly, the tactic in Java may be a collection of instructions that performs a sel...