C C++ program to find largest maximum element in Array

C C++ program to find largest maximum element in Array

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

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C और C++ दोनों भाषाओं में महत्वपूर्ण अंतर क्या है जानने के लिए देखें—C vs C++

C program to find largest maximum element in Array

#include<stdio.h>
int main()
{
    int num[5],i,large;
    printf("Enter elements of array: \n");
    for(i=0;i<5;i++)
    {
        scanf("%d",&num[i]);
    }
    large=num[0];
    for(i=0;i<5;i++)
    {
        if(num[i]>large)
        {
            large=num[i];
        }
    }
    printf("Largest element = %d\n",large);
    return 0;
 }

C++ program to find largest maximum element in Array

#include<iostream>
using namespace std;
int main()
{
    int num[5],i,large;
    cout<<"Enter elements of array: \n";
    for(i=0;i<5;i++)
    {
        cin>>num[i];
    }
    large=num[0];
    for(i=0;i<5;i++)
    {
        if(num[i]>large)
        {
            large=num[i];
        }
    }
    cout<<"Largest element = "<<large;
    return 0;
 }

Output of C C++ program to find largest maximum element in Array

C CPP program to find largest element in Array

Some useful C and C++ array based programs

  1. Declaration and initialization of array
  2. Input-output in array
  3. Sum and average of array elements
  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