Home TechnologyProgramming Subscribe to RSS

Write A Program In "C" To Find Out Greatest Of Three Numbers?

Answer Question

4 Answers - Sort by: Date | Rating

    #include
    #include
    void main()
    {
    clrscr();
    int a,b,c;
    printf("nt Enter the first number : ");
    scanf("%d",&a);
    printf("nt Enter the second number : ");
    scanf("%d",&b);
    printf("nt Enter the third number : ");
    scanf("%d",&c);
    if(a>b && a>c)
    printf("nt The greatest number is : %d ",a);
    if(b>a && b>c)
    printf("nt The greatest number is : %d ",b);
    if(c>a && c>b)
    printf("nt The greatest number is : %d ",c);
    getch();
    }
    1 0
    Guest

    Guest 

    answered 6 months ago

      Here is the gretest of three numbers. And yes if you need for more numbers just increase SIZE, no more changes needed.

      #include<stdio.h>
      #include<conio.h>
      #define SIZE 3

      void main()
      {
      int Nums[SIZE], i,Greatest=0;
      printf("Enter three numbers: ");
      for(i=0;i<SIZE;i++)
      scanf("%d",&Nums[i]);

      for(i=0;i<SIZE;i++){
      if (Greatest<Nums[i])
      Greatest=Nums[i];
      }
      printf("Greatest number is:t %d",Greatest);
      getch();
      }
      0 0

      Alon_nad 

      answered 4 months ago

        Mesak Lawmkima, Jr.Technician(Software) - Member of Faculty, ZENICS Computer Academy, Aizawl, Mizoram
        #include
        void main()
        {
        int x, y, z;
        clrscr();
        printf("Enter any three numbers : ");
        scanf("%d %d %d", &x, &y, &z)
        if(x>y>z)
        {
        printf("The first number is greatest");
        }
        if(y>z>x)
        {
        printf("The second number is greatest");
        }
        if(z>x>y)
        {
        printf("The third number is greatest");
        }
        getch();
        }
        0 0
        Guest

        Guest 

        answered 4 months ago

        Helo.........thank u so much
        it was very helpful for me
        Report
        Kasani

        Kasani

        commented 2 months ago

        #include<iostream.h>

        #include<conio.h>

        #include<stdio.h>

        void main()

        {

        clrscr();

        int a,c,b;


        cout<<"enter three numbers";

        cin>>a;

        cin>>b;

        cin>>c;


        if(a>b && a>c)

        {

        cout<<a<<"is the greatest of all"<<endl;

        }

        else if(b>a && b>c)

               {

        cout<<b<<"is greatest of all"<<endl;

        }

        else if(c>a && c>b)

        {


        cout<<c<<"is greatest of all"<<endl;

        }

        getch();

        }

        0 1

        Tahir90 

        answered 6 months ago

        Answer Question - Answers are editable for 5 min.

        If you do not Sign-in or Register your answers will

        be anonymous, your answers may also be

        checked before going online.

        0

        More

        More

           
           

          Ask a Question via Twitter

          Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

          Blurtit Store

          Get T-shirts, hoodies, caps and more at the Blurtit store

          Blurtit International