Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/articles/c-tutorials/)
-   -   Calculation of largest no as they are entered. (http://www.go4expert.com/articles/calculation-largest-entered-t690/)

 coderzone 5Apr2006 21:30

Calculation of largest no as they are entered.

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);}`

 rai_gandalf 9May2006 23:21

Re: Calculation of largest no as they are entered.

Thx. May be useful 4 some of the C progs I hav in mind.

Ciao,
Rajiv

;)

 debleena_doll2002 20Feb2008 14:47

Re: Calculation of largest no as they are entered.

Quote:
 Originally Posted by rai_gandalf Thx. May be useful 4 some of the C progs I hav in mind. Ciao, Rajiv ;)

:iagree:

Re: Calculation of largest no as they are entered.

good info

 crazytolearn57 26Feb2008 18:37

Re: Calculation of largest no as they are entered.

good one

 aisha.ansari84 5Mar2008 18:38

Re: Calculation of largest no as they are entered.

good one

 All times are GMT +5.5. The time now is 14:21.