Friday, 25 December 2020

Write a program in C++ to find the sum and average of “N” numbers.

#include <iostream>

using namespace std;

main()

{

  int N,Num,Sum=0,avg;

  cout<<"Enter the Number of Numbers\n";

  cin>>N;

  for(int i=1;i<=N;i++)

  {

    cout<<"Enter a Number\n";

    cin>>Num;

    Sum=Sum+Num;

  }

   avg=Sum/N;

   cout<<"Sum= "<<Sum<<"\n"<<"Average= "<<avg;

}


No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...