Programming Examples

C program to find the largest value in integer array


Write a C Program which accept the n number of elements from user and find the largest element of array.

Solution

 #include<stdio.h>
 int main()
 {
 	int num[100],n,a,max;
 	printf("How many elements you want to enter (max:100): ");
 	scanf("%d",&n);
 	for(a=0;a<n;a++)
 	{
 		scanf("%d",&num[a]);
	}
	max=num[0];
	for(a=1;a<n;a++)
	{
		if(max<num[a])
		{
			max=num[a];
		}
	}
	printf("Largest Element is: %d",max);
	return 0;
 }
Output

How many elements you want to Enter (max:100): 5

4 5 6 2 3

Largest Element is: 6

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz