# Write a program to find the largest element in an array using Recursion – IGNOU MCA Assignment 2017 – 18

By | November 22, 2017

MASTER OF COMPUTER APPLICATIONS
Course Code: MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(1)/011/Assign/2017-18
Maximum Marks : 100

Write a program to find the largest element in an array using Recursion – IGNOU MCA Assignment 2017 – 18

Program:

#include<stdio.h>
int LARGE=-1;
void main()
{
int NUM[10],I;
void largest_rec(int *);
clrscr();
printf(“ENTER TEN NUMBERS TO COMPARE\n”);
for(I=0;I<10;I++)
{
printf(“\nENTER NUMBER : “);
scanf(“%d”,&NUM[I]);
}
largest_rec(NUM);
printf(“\nTHE LARGER NUMBER IS %d”,LARGE);
getch();
}

void largest_rec(int *TEMP)
{
if(*TEMP)
{
if(LARGE<*TEMP)
LARGE=*TEMP;
largest_rec(TEMP+1);
}
}

Code:

 Source code
```#include<stdio.h>
int LARGE=-1;
void main()
{
int NUM[10],I;
void largest_rec(int *);
clrscr();
printf("ENTER TEN NUMBERS TO COMPARE\n");
for(I=0;I<10;I++)
{
printf("\nENTER NUMBER : ");
scanf("%d",&NUM[I]);
}
largest_rec(NUM);
printf("\nTHE LARGER NUMBER IS %d",LARGE);
getch();
}
void largest_rec(int *TEMP)
{
if(*TEMP)
{
if(LARGE<*TEMP)
LARGE=*TEMP;
largest_rec(TEMP+1);
}
}```

Screen Shots: