beginner c++ need help please

This is a discussion on beginner c++ need help please within the C++ Programming forums, part of the General Programming Boards category; i really need help my assigment is due tomorrow morning and iam stuck on this. When i select gate number ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    96

    beginner c++ need help please

    i really need help my assigment is due tomorrow morning and iam stuck on this.
    When i select gate number 2 its OR from logic gates i input 0 ,1 i should get a 1 for a logic gate. and iam getting a 0. can someone please help me
    Code:
    
    #include <iostream>
    inline int OR(int x, int y)
    {      if(x==0||y==0)
           {
           return (0); 
           }
           else
           return(1);
     }
    using namespace std;
    
    int main()
    {
    	int i, choice,gate1,gate2,x;
    	cout<<"Types of gates available"<<endl;
    	cout<<"1. AND"<<endl;
    	cout<<"2. OR"<<endl;
    	
    	
    	cout<<"select gate # (1 to 5) =>";
    	cin>>choice;
    	
    		if(choice==2)
    		{
    		cout<<"Enter two inputs for gate #"<<1<<endl;
    		cin>>gate1>>gate2;
    		x = OR(gate1,gate2);
    		cout<<x;
                                }
    	
    	cin.sync();
        cin.get();
    	return 0;
    }

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Who taught you about logic gates?
    Code:
    inline int OR(int x, int y)
    {      if(x==0||y==0)
           {
           return (0); 
           }
           else
           return(1);
     }
    You don't see a serious problem with the part in red?

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    96
    got it
    Last edited by mouse666666; 09-27-2010 at 11:42 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ADO.NET in VS2008 or gdi+ (beginner question)
    By robgar in forum C# Programming
    Replies: 3
    Last Post: 10-04-2009, 03:40 AM
  2. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 12:48 PM
  3. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 03:02 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM

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