/****************************
* Umang B Bhatt *
* bhatt.umang7@gmail.com *
*****************************/
/**
* program for scannign n numbers and finding the biggest from them
*/
#include<stdio.h>
void main()
{
int n = 0 , i =0 , j = 0;
int no[100];
int biggest; // for storing the biggest number
printf("How many numbers you want to scan ? ");
scanf("%d",&n);
if(n < 0 || n>100)
{
// if the user enters invalid no of elemtns then we come here
printf("Invalid number. It must be brtween 1 to 100");
}
else
{
// logic for scanning the numbers
for(i = 0 ; i < n ;i++)
{
printf("Enter element %d: ", i);
scanf("%d",&no[i]);
}
// assign biggest the first element's value
biggest = no[0];
// the logic for finding the biggest number
for(i = 0 ; i < n ;i++)
{
if(no[i] > biggest)
{
biggest = no[i];
}
}
printf("The biggest number among those numbers is: %d" , biggest);
}
printf("\n");
}
Showing posts with label biggest number from array. Show all posts
Showing posts with label biggest number from array. Show all posts
Monday, December 27, 2010
finding the biggest number from array
Subscribe to:
Posts (Atom)