Tuesday, 22 July 2014

How To Find Largest Among Few Number Without Using Array..

This Program Will Find Out The Largest Among Few user Given Number. The Numbers Entered By The User Must Be Positive.

#include<stdio.h>
#include<conio.h>
main()
      {
       int a,b,i,n;
       b=0;
       printf("\n\tEnter How Many Number You Want To Enter:==");
       scanf("%d",&n);
       for(i=0;i<n;i++)
                       {
                        input:
                              {
                               printf("\n\tEnter No[%d]:==",i+1);
                               scanf("%d",&a);           
                              }        
                        if(a<0)
                               {
                                printf("\n\tThe Input Was Wrong Number Must Be 0 Or Positive");
                                goto input;        
                               }
                        else
                            {
                             if(a>=b)
                                     {
                                      b=a;              
                                     }   
                            }
                       }
       printf("\n\tThe Largest Number You Have Entered:==%d",b);
       getch();
      }

No comments:

Post a Comment