Friday, 15 January 2021

WAP in C++ to read and display the sum of elements in a Single Dimensional array.

#include <iostream>

using namespace std;

main()

{

  int N,i,sum=0;

  cout<<"Enter the size of the array\n";

  cin>>N;

  int arr[N];

  cout<<"Enter "<<N<<" Numbers\n";

  for(i=0;i<N;i++)

  {

  cin>>arr[i];

  sum=sum+arr[i];

  }

  cout<<"The Sum of the elements of the array is: "<<sum;

}

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...