help

This is a discussion on help within the C++ Programming forums, part of the General Programming Boards category; It says "Invalid number" when i write 1 on a and 1 on b when i start the program, whats ...

  1. #1
    Banned
    Join Date
    May 2004
    Posts
    55

    help

    It says "Invalid number" when i write 1 on a and 1 on b when i start the program, whats wrong? im a newbie on c++
    Code:
    #include <iostream.h>
    #include <cstdio> //for pause the program
    using namespace std; //for pause the program
    main()
    {
        char a;
        char b;
        cout<<"First '+' number: ";
        cin>>a;
        cout<<"Secound '+' number: ";
        cin>>b;
        if(a==1&&b==1)
    {
        cout<<"1+1=2";
    }
        else
    {
        cout<<"Invalid number";
    }
        getchar();//for pause the program
        getchar();//for pause the program
        return 0;
    }
    please help

  2. #2
    Registered User ventolin's Avatar
    Join Date
    Jan 2004
    Posts
    92
    Code:
    #include <iostream.h>
    #include <cstdio> //for pause the program
    using namespace std; //for pause the program
    main()
    {
        int a;
        int b;
        cout<<"First '+' number: ";
        cin>>a;
        cout<<"Secound '+' number: ";
        cin>>b;
        if(a==1&&b==1)
    {
        cout<<"1+1=2";
    }
        else
    {
        cout<<"Invalid number";
    }
        getchar();//for pause the program
        getchar();//for pause the program
        return 0;
    }

  3. #3
    Banned
    Join Date
    May 2004
    Posts
    55
    oki thnks =)

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21