C++ Program by using pointer that receives array of 5 integers numbers and calculate the sum, average and standard deviation of these numbers.

C++ Program Calculate the Sum, Average and standard Deviation of these Numbers.

C++ program by using pointer that receives array of 5 integers from keyboard and calculate the sum, average and standard deviation of these numbers.

Object: Write a C++ program by using pointer that receives array of 5 integers from keyboard and calculate the sum, average and standard deviation of these numbers.

Code:

#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
void main()
{
     int num[5],i,sum=0,avg,stdvi,var=0;
     int *p[5];
     cout<<“Enter 5 Numbbers:\n”;
     for(i=0;i<5;i++)
     {
         cin>>num[i];
         p[i]=&num[i];
         sum+=*p[i];
     }
     avg=sum/5;
     for(i=0;i<5;i++)
     {
         var+=pow(num[i]-avg,2);
         var=var/5;
         stdvi=sqrt(var);
     }
     cout<<“Sum of 5 Numbers is: “<<sum;
     cout<<“\nAverage of 5 Numbers is: “<<avg;
     cout<<“\nStandard deviation of these Numbers is: “<<stdvi;

     getch();
}

Output:

C++ Program by using pointer that receives array of 5 integers numbers and calculate the sum, average and standard deviation of these numbers.

M.A Siddiqui

Hi, I am M.A Siddiqui. I'm a Computer Science Student, In this website, I'm teaching you Multiple languages and provides Projects and other Subjects Notes.

You may also like...

1 Response

  1. June 14, 2020

    […] C++ Program by using pointer that receives array of 5 integers numbers and calculate the sum, averag… […]

Leave a Reply

Your email address will not be published. Required fields are marked *