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 assigns values to the individual elements of an array and displays the values of the array.

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

Write a program that assigns values into the individual elements of an array and displays the values of the array.

So let’s Write Code:

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

Let’s build logic First:

Algorithm for code:

  • Step 1: Start
  • Step 2: Declare an array.
  • Step 3: Initialize Array elements.
  • Step 4: Print Elements.
  • Step 5: Finish Program

Code:

Write a program that assigns values to the individual elements of an array and displays the values of the array.

#include<iostream>
using namespace std; 
main()
{
int temp[5], i;
temp[0] = 2;
temp[1] = 20;
temp[2] = 15;
temp[3] = 254;
temp[4] = 5;
for(i = 0; i<=4; i++)
cout<<"Value in temp["<<i<<"] = "<<temp[i]<<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 declaration in c++, array elements, Array Exercises, Array exercises in C++, array in c++ with example, array in Object oriented programming, array in OOP, Arrays, Arrays in C++, assign vales to array in c++, assign values to array, C++ array, C++ array: declare, c++ arrays declaration and initialization, Creating and Using Arrays, How do you assign all values to one array?, How do you assign values to an array?, How do you display the elements of an array?, how to creat an array in c++, how to store array elements in c++, initialize, What is used to access individual value in an array?, Write a program that assigns values into the individual elements of an array and displays the values of the array., write c++ program to assign values to an array

Post navigation

Previous Post: Write a program that gets 5 integer values into an array and then displays the values of the elements of the array in reverse order.
Next Post: Write a program that initializes the values in the one-dimensional array and computes the sum of even values.

More Related Articles

Write a Program to Build a Simple Calculator in Java Write a Program to Make a Simple Calculator in Java Programming Language | Solved Programming Exercises Programming Exercises
Write a program that sorts an array in ascending order by passing the array to a function. Arrays Exercises
Write a program that sorts one-dimensional array’s values into descending order using the bubble sort method. Arrays Exercises
Write a program that inputs integer values in an array of 10 elements in main() function and passes the array to a function. The function counts odd integer values. Arrays Exercises
Write a program that inputs marks of ten students in an array and counts the number of students that have marks between 80 and 100. Arrays Exercises
Write a program to input an array of 10 elements from the user and count the number of odd numbers and display it. Arrays Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme