C C++ program for declaration and initialization of array

C C++ program for declaration and initialization of array

C Language में Array और इसके विभिन्न प्रकारो के बारे में और अधिक जानने के लिए देखें— Arrays in C

Pointer to array क्या होता है जानने के लिए देखें—Pointer to array in C

C Language में Character Array या String किसे कहते है जानने के लिए देखें हमारा यह पोस्ट— Strings in C

C program for declaration and initialization of array

#include<stdio.h>
int main()
{
    int a[5]={5,1,9,7,2};
    printf("Number1 = %d",a[0]);
    printf("\nNumber2 = %d",a[1]);
    printf("\nNumber3 = %d",a[2]);
    printf("\nNumber4 = %d",a[3]);
    printf("\nNumber5 = %d",a[4]);
    return 0;
}

C++ program for declaration and initialization of array

#include<iostream>
using namespace std;
int main()
{
    int a[5]={5,1,9,7,2};
    cout<<"Number1 = "<<a[0]<<endl;
    cout<<"Number2 = "<<a[1]<<endl;
    cout<<"Number3 = "<<a[2]<<endl;
    cout<<"Number4 = "<<a[3]<<endl;
    cout<<"Number5 = "<<a[4]<<endl;
    return 0;
 }

Output of C C++ program for declaration and initialization of array

Program for Declaration and initialization of array in C C++

Related array example programs in C C++

  1. Input-output in array
  2. Sum and average of array elements
  3. Largest Element in Array
  4. Smallest element in Array
  5. Reverse Elements of Array
  6. Merging two arrays
  7. Searching in array (Linear search)
  8. Sorting in array (Selection sort)
  9. Pointer to array
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer