View Single Post
Old 15-09-2007, 06:37 AM   #139 (permalink)
Gigacore
Dreamweaver
 
Gigacore's Avatar
 
Join Date: Aug 2006
Location: Bangalore
Posts: 3,904
Default Re: Post ur C/C++ Programs Here

C Program to find the largest element in an array and the position of its occurrence.

Code:
#include <stdio.h>
#include <conip.h>
void main()
{
	int a[100];
	int largest,position,num,index;
	scanf("%d",&num);
	for(index=0;index<num;index++)
		scanf("%d",&a[index]);
	largest=a[0];
	position=0;
	for(index=1;index<num;index++)
	{
		if(largest<a[index])
		{
		largest = a[index];
		position=index;
		}
	}
	printf("Largest element in the array is %d \n", largest);
	printf("Largest element's position in the array %d\n", position+1);
	return 0;
Getch();
}
__________________
Today's noobs are tomorrow's geeks. Don't make fun of them.. encourage them. - Gigacore

Follow me on twitter.com/gigacore

Last edited by Gigacore; 30-10-2007 at 06:48 PM.
Gigacore is offline