Header Ad

C Program to find the largest of two number using the function

This tutorial will write a C Program to find the largest of two numbers using the function in C Programming with practical program code and step-by-step full complete explanation.


C Program to find the largest of two numbers using the function

 
#include<stdio.h>
#include<conio.h>

void main()
{
	void max();

	clrscr();

	max();

	getch();
}

void max()
{
	int max,n,i;

	printf("How many numbers you want to enter: ");
	scanf("%d",&n);
    
    int a[n];

	printf("Enter element for the array: ");
	for(i=0;i<n;i++)
	{
	scanf("%d",&a[i]);
	}

	max=a[0];

	for(i=1;i<n;i++)
	{
		if(max<a[i])
		{
			max=a[i];
		}
	}
	printf("Maximum number=%d",max);
}


Output

 
How many numbers you want to enter: 4
Enter element for array: 4
5
6
1


Post a Comment

0 Comments