1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Calculation of largest no as they are entered.

Discussion in 'C' started by coderzone, Apr 5, 2006.

  1. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    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:
    #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);
    }
     
  2. rai_gandalf

    rai_gandalf New Member

    Joined:
    Nov 4, 2005
    Messages:
    46
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Final Year Comp Engg
    Location:
    Mumbai
    Home Page:
    Thx. May be useful 4 some of the C progs I hav in mind.

    Ciao,
    Rajiv

    ;)
     
  3. debleena_doll2002

    debleena_doll2002 New Member

    Joined:
    Feb 5, 2008
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    0

    :iagree:
     
  4. lead.smart34

    lead.smart34 New Member

    Joined:
    Feb 14, 2008
    Messages:
    77
    Likes Received:
    0
    Trophy Points:
    0
    good info
     
  5. crazytolearn57

    crazytolearn57 New Member

    Joined:
    Feb 14, 2008
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    0
  6. aisha.ansari84

    aisha.ansari84 New Member

    Joined:
    Feb 13, 2008
    Messages:
    82
    Likes Received:
    1
    Trophy Points:
    0

Share This Page