Calculation of largest no as they are entered.

coderzone's Avatar author of Calculation of largest no as they are entered.
This is an article on Calculation of largest no as they are entered. in C.
The below program calculates the largest no among the no entered but it just calculates as user inputs them. This can be used with files and as you move ahead in file you can store the max and the min value in a variable when parsing the file.
Code: C
#include<stdio.h>

int largest(int,int);

void main()
{
    int n,m,i;
    printf("Go on entering numbers\n");
    scanf("%d",&n);
    for(i=1;i<=10;i++)
    {
        scanf("%d",&m);
        m=largest(n,m);
        printf("%d\t",m); /*prints the largest of the number inputed till now*/
        n=m;
    }
}
int largest(int n,int m)
{
    if(n>m)
        m=n;
    return(m);
}
Go4Expert Member
9May2006,23:21   #2
rai_gandalf's Avatar
Thx. May be useful 4 some of the C progs I hav in mind.

Ciao,
Rajiv

Ambitious contributor
20Feb2008,14:47   #3
debleena_doll2002's Avatar
Quote:
Originally Posted by rai_gandalf
Thx. May be useful 4 some of the C progs I hav in mind.

Ciao,
Rajiv


Contributor
26Feb2008,18:19   #4
lead.smart34's Avatar
good info
Go4Expert Member
26Feb2008,18:37   #5
crazytolearn57's Avatar
good one
Contributor
5Mar2008,18:38   #6
aisha.ansari84's Avatar
good one