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:
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/