// onlyme.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include<stdlib.h>
using namespace std;
int inputa;
int inputb;
int Andgate(void);
int orgate(void);
int notgate(void);
int andgate(void)
{
    cout<<"input Gate A, enter 1 or 0, enter 2 to end program ";
    cin>>inputa;
    cout<<"input Gate B, enter 1 or 0, enter 2 to end program ";

    cin>>inputb;
    if (inputa == 2 || inputb == 2)
    {
        return 0;
    }


    if (inputa== 1 && inputb == 1)
    {
        cout<<"Output is logic one \n";
    }
    else
    {
        cout<<"Output is logic zerro \n";
    }

    andgate();
}
int orgate()
{
    cout << "input Gate A, enter 1 or 0, enter 2 to end program";
    cin >> inputa;
    cout << "input Gate B, enter 1 or 0, enter 2 to end program ";

    cin >> inputb;
    if (inputa == 2 || inputb == 2)
    {
        return 0;
    }
    if (inputa == 0 || inputb == 1||inputa==1||inputb==0)
    {
        cout << "Output is logic one \n";
    }
    else
    {
        cout << "Output is logic zerro \n";
    }


}
int notgate()
{
    cout << "input Gate A, enter 1 or 0, enter 2 to end program";
    cin >> inputa;
    cout << "input Gate B, enter 1 or 0, enter 2 to end program ";

    cin >> inputb;
    if (inputa == 2 || inputb == 2)
    {
        return 0;
    }
    if (inputa ==!0||inputb==!1 )
    {
        cout << "output is ligic one\n";
    }
    else
    {
        cout << "output is logic zero\n";

}
int _tmain(int argc, _TCHAR* argv[])
{
    int choice;
    while (1)
    {

        cout << " enter 1 to and gate\n enter 2 to or gate\n  enter 3 to notgate ";
        cin >> choice;
        switch (choice)
        {
        case 1:
            Andgate();
            break;
        case 2:
            orgate();
            break;
        case 3:
            notgate();
            break;
        case 4:
            exit(0);


        }

    }
    system("pause");
    return 0;
}

please correct my errors

this thread belongs to function in c++ so i am not sure why you give such a title(bitwise operator) to the thread.

however , right now , i am not familiar with functions(i can't pass any suggestions on function related issues) but i found 2 mistakes there in your code and these are :

1.you declare prototype with name Andgate(void); and defining andgate().again you done a mistake of calling Andgate();(line no.90). so the call should be andgate(); instead of Andgate();.So replace Andgate to andgate.[c++ is case sensitive language]

2.In line 77 there is missing closing curly brace. so also add curly brace at line 77.

Edited 3 Years Ago by Learner010

Whats is your error and also what do you intend to achieve with your code. Give more information next time you ask for a help. We cant read your mind.

This article has been dead for over six months. Start a new discussion instead.