C++ progrrame to find the greates integer...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • snehil
    New Member
    • Jun 2009
    • 19

    C++ progrrame to find the greates integer...

    Hi.. I'm a very beginner in C++
    I was trying to make a programme to find biggest of three nos. but the programme dat i made is not returning the desired solutin. Pls help me out with this..and also please explain the problem to me.. Thanx..in advance...
    [code=cpp]#include <iostream.h>
    #include <conio.h>
    void main()
    {
    clrscr();
    int a,b,c;
    cout<<"Please enter three nos. ";
    cin>>a>>b>>c;
    if (a>b)
    {
    if (a>c)
    cout<<"a is largest";
    else
    cout<<"c is largest";
    }
    else if (b>c)
    cout<<"b is largest";

    getch();
    }
    [/code]
    The problem is that when a and b are largest.. theres no error.. but when c is greatest. there is problem some times..
    for instance.. when i input.. a=89, b=59, c=99
    C is displayed as largest..
    but when I am inputting a=59, b=89, c=99
    there is no out put coming... :-/
  • snehil
    New Member
    • Jun 2009
    • 19

    #2
    Solved..
    I was missing a statement..sill y me...
    [code=cpp]#include <iostream.h>
    #include <conio.h>
    void main()
    {
    clrscr();
    int a,b,c;
    cout<<"Please enter three nos. ";
    cin>>a>>b>>c;
    if (a>b)
    {
    if (a>c)
    cout<<"a is largest";
    else
    cout<<"c is largest";
    }
    else if (b>c)
    cout<<"b is largest";
    else
    cout<<"c is largest";
    getch();
    }
    [/code]
    this programme is now working fine.. :)

    Comment

    Working...