About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Monday, September 2, 2013

C Program to Find Largest Element in Array in C Programming

// ------------------------------------------
// Title : Find out Largest Number From Array
// Largsest - It Stores the Largest number
// ------------------------------------------
#include<stdio.h>
#include<conio.h>
void main()
  {
  int a[30],i,n,largest;

  printf("n Enter no of elements :");
  scanf("%d",&n);

  /* read n elements in an array  */
  for(i=0 ; i < n ; i++)
     scanf("%d",&a[i]);

  largest = a[0];

  for(i = 0;i<n;i++)
  {
  if(a[i] > largest )
      largest = a[i];
  }

  /* Print out the Result */
     printf("Largest Element : %d",largest);
     getch();
}

No comments: