Tech Study

C++ Program To Read And Print Elements Of Array

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.

#include <iostream>
#define MAX_SIZE 100 //Maximum size of the array
using namespace std;
 
int main()
{
    int arr[MAX_SIZE]; //Declares sizr of array
    int i, num;
    cout<<"Enter size of array: ";
    cin>>num;
 
    cout<<"Enter "<<num<< " elements in the array :";
 
    //Reads size & elements in array
    for(i=0; i<num; i++)
    {
        cin>>arr[i];
    }
 
    //Prints all elements of array
    cout<<"\nElements in array are: ";
    for(i=0; i<num; i++)
    {
        cout<<arr[i]<<"\t";
    }
 
    return 0;
}

Result

Write C++ program to read and print elements of array
Write C++ program to read and print elements of array

 

Here are some more example of c++ program for practice :

C++ Program to Enter Month and Print Days.

 C++ program to sort an array in ascending order

c++program to accept two integers and check they are equal or not

C++ program to print day name of week

TaggedWrite C++ program to read and print elements of array

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more