Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form

Write a program that inputs ten values in an array and calculates the sum of these values.

Posted on October 15, 2021October 15, 2021 By myustaadg.com
Spread the love

Write a program that inputs ten values in an array and calculates the sum of these values.

So let’s Write Code:

Introduction to C++ Programming | Download and Install Dev C++ Compiler

Let’s build logic First:

Algorithm of Code:

  • Step 1: Start
  • Step 2: Declare and intialize an array of 10 elements.
  • Step 3: Declare and initialize a variable s=0 for store the values of sum.
  • Step 4: Take Inputs from user.
  • Step 5: Repeat Step 6, 7, 8 until i<=9
  • Step 6: Read the curent index value
  • Step 7: Add array elements in s as s = s + ar[ i]
  • Step 8: i++
  • Step 9: Print s

Write a program that inputs ten values in an array and calculates the sum of these values.

#include<iostream>
using namespace std;
main()
{
int ar[10], s = 0;
for(int i=0; i<=9; i++) 
{
cout<<"Enter value in element "<<i<<" ? ";
cin>>ar[i];
s = s + ar[i];
}
cout<<"Sum of array is : "<<s<<endl;
}

Hope You will learn Something. Happy Coding.

Visit my YouTube Channel as Well😇 https://www.youtube.com/watch?v=JuIHQ9cLSEw&list=PLbIhkHxfUIItTdcyCb34uRIrPJbXBndIl&index=4

Click on the below Links for more Programming Exercises:

Conditional Structure Exercises: 👉https://myustaadg.com/category/programming-exercises/conditional-structures-exercises/

Array Exercises: 👉https://myustaadg.com/category/programming-exercises/arrays-exercises/

Arrays Exercises, Programming Exercises Tags:array in c programming examples pdf, array in class c++, array in computer programming, array in while loop, Arrays in C++ Programming with examples, c++ Array declare, C++ array programs, C++ Arrays with examples, C++ exercises, C++ programs, calculates the sum of the values in array, calculates the sum of the values in array using a function, calculates the sum of the values in array using c++, calculates the sum of the values in array using descending order, calculates the sum of the values in array using function calculates the sum of the values in array using example, calculates the sum of the values in array using in c++, calculates the sum of the values in array using while loop, for loop, how do you initialize an array in c++, how to print array in C++, how to store values in an array in C++, nputs ten values in an array and calculates the sum of these values., take 10 integer input from user and store then in array and print then on screen, write a C++ program to input values into an array and display tem, write a program in c++ to store elements in an array and print it, write a program that inputs of values in an array, write a program that inputs with values in an array, write a program to input 10 values in array

Post navigation

Previous Post: Write a Program that Inputs Values into an Array and Displays the Values of the Array
Next Post: Write a program that inputs fifteen integer values in an array. It finds out all the prime numbers.

More Related Articles

Write a program in C++ that inputs data into an array. It inputs a value from the user and searches this value in the array using sequential search. Arrays Exercises
Write a program that asks the user for the number of hours worked and the cost per hour. Then show payment on the screen that corresponds to you | Python Programming Programming Exercises
Write a program that inputs values into an array. It multiplies the even values of elements with 5, odd values with 4 and adds the new values of an array. Arrays Exercises
Write a program that initializes values in two tables A and B. It adds tables A and B and stores result into table C. It also displays the values of three tables in tabular form on the screen. Arrays Exercises
Write a program that asks the user for two numbers and shows their division on the screen. If the divisor is zero the program must display an error | Python Programming Programming Exercises
Write a program that inputs the names of students of a class and displays them in ascending and descending order. Arrays Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme