Thread: Choice menu errors

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    12

    Exclamation Choice menu errors

    I have tried to create a choice menu, I am coming up with several error C2143's saying I am missing ')' before ;

    which I don't think I need, If anyone could help me with this, maybe it is a simple mistake or two, but it's really important I get this sorted ASAP #assignment

    Code:
    #include<stdio.h>#include<stdlib.h>
    #include<conio.h>
     
    int And(int x, int y);
    int Not(int x);
    int Or(int x, int y);
    int multiplexer(int a, int b, int c);
    int Xor(int x, int y);
    int Xnor(int x, int y);
    int Nand(int x, int y);
    int Nor(int x, int y);
    int full_adder_sum(int a, int b, int c);
    int full_adder_carry(int a, int b, int c);
    int full_adder_extra_carry(int a, int b, int full_adder_carry);
    int choice;
    
    
    
    
    int main(void)
    {
        int a;
        int b;
        int c;
     
        printf("\nEnter Value for A: ");
        scanf_s("%i", &a);
     
        printf("\nEnter Value for B: ");
        scanf_s("%i", &b);
     
        printf("\nEnter Value for C: ");
        scanf_s("%i", &c);;
    
    
    	int choice;
    do
    		{
    			printf("Menu\n\n");
    			printf("1. Simulate Multiplexer\n");
    			printf("2. Simulate Full Adder\n");
    			printf("3. Simulate Next Carry from Full Adder\n");
    			printf("4. Exit\n");
    			scanf("%d",&choice);
       
    			switch (choice)
    			{
    				case 1:	printf("\n\nOutput from Multiplexer = %d", multiplexer(a, b, c));
    						system("PAUSE");
    							break;
    				case 2:	printf("\n\nSum from Full Adder = %d", full_adder_sum(a, b, c);
    						printf("\nCarry from Full Adder = %d", full_adder_carry(a, b, c);
    						system("PAUSE");
    							break;	
    				case 3:	printf("\n\n Next Carry from Full Adder = %d", full_adder_extra_carry(a, b, full_adder_carry);
    						system("PAUSE");
    							break;
    case 4:	printf("\n\nQuitting in 3 seconds\n");
    						sleep(3000);
    						exit(0);
    							break;
    default: printf("Wrong Choice. Enter again\n");
    							break;
    			}    
      
    		} while (choice != 4);
    }
     
    int Not(int x)
    {
        return !x;
    }
     
    int And(int x, int y)
    {
        return x && y;
    }
     
    int Or(int x, int y)
    {
        return x || y;
    }
    
    
    int Xor (int x, int y)
    {
    	if (x==0 && y==0)
    return 0;
    	if (x==0 && y==1)
    return 1;
    	if (x==1 && y==0)
    return 1;
    	if (x==1 && y==1)
    return 0;
    }
    int Xnor (int x, int y)
    {
    	if (x==0 && y==0)
    return 1;
    	if (x==0 && y==1)
    return 0;
    	if (x==1 && y==0)
    return 0;
    	if (x==1 && y==1)
    return 1;
    }
    int Nand (int x, int y)
    {
    	if (x==0 && y==0)
    return 1;
    	if (x==0 && y==1)
    return 1;
    	if (x==1 && y==0)
    return 1;
    	if (x==1 && y==1)
    return 0;
    }
    int Nor (int x, int y)
    {
    	if (x==0 && y==0)
    return 1;
    	if (x==0 && y==1)
    return 0;
    	if (x==1 && y==0)
    return 0;
    	if (x==1 && y==1)
    return 0;
    }
    //MULTIPLEXER
    int multiplexer(int a, int b, int c)
    {
        return Or((And(a, (Not (c)))), (And(b, c)));
    }
    //FULL ADDER
    int full_adder_sum(int a, int b, int c)
    {
    	return Xor(a, (Xor(b, c)));
    }
    int full_adder_carry(int a, int b, int c)
    {
    	return Or((And(a, b)), (And(c, (Or(a, b)))));
    }
    //FULL ADDER WITH EXTRA CARRY
    int full_adder_extra_carry(int a, int b, int full_adder_carry)
    {
    	return Or((And(a, b)), (And(full_adder_carry, (Or(a, b)))));
    }
    

  2. #2
    Registered User
    Join Date
    Oct 2011
    Location
    Denmark
    Posts
    80
    You are missing closing parenthesis line 52, 53 and 56. But you might have other problems .
    HomePort : A C Web Service API for heterogeneous home automation systems

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    12

    Question

    Quote Originally Posted by Tibo-88 View Post
    You are missing closing parenthesis line 52, 53 and 56. But you might have other problems .
    Cheers, updated it...now I have error

    C2143: syntax error : missing ';' before 'type'
    on line 34
    but there is no need for another ; ?

    Code:
    #include<stdio.h>#include<stdlib.h>
    #include<conio.h>
     
    int And(int x, int y);
    int Not(int x);
    int Or(int x, int y);
    int multiplexer(int a, int b, int c);
    int Xor(int x, int y);
    int Xnor(int x, int y);
    int Nand(int x, int y);
    int Nor(int x, int y);
    int full_adder_sum(int a, int b, int c);
    int full_adder_carry(int a, int b, int c);
    int full_adder_extra_carry(int a, int b, int full_adder_carry);
    int choice;
    
    
    
    
    int main(void)
    {
        int a;
        int b;
        int c;
     
        printf("\nEnter Value for A: ");
        scanf_s("%i", &a);
     
        printf("\nEnter Value for B: ");
        scanf_s("%i", &b);
     
        printf("\nEnter Value for C: ");
        scanf_s("%i", &c);
    
    
    	int choice;
    do
    		{
    			printf("Menu\n\n");
    			printf("1. Simulate Multiplexer\n");
    			printf("2. Simulate Full Adder\n");
    			printf("3. Simulate Next Carry from Full Adder\n");
    			printf("4. Exit\n");
    			scanf("%d",&choice);
       
    			switch (choice)
    			{
    				case 1:	printf("\n\nOutput from Multiplexer = %d", multiplexer(a, b, c));
    						system("PAUSE");
    							break;
    				case 2:	printf("\n\nSum from Full Adder = %d", full_adder_sum(a, b, c));
    						printf("\nCarry from Full Adder = %d", full_adder_carry(a, b, c));
    						system("PAUSE");
    							break;	
    				case 3:	printf("\n\n Next Carry from Full Adder = %d", full_adder_extra_carry(a, b, full_adder_carry));
    						system("PAUSE");
    							break;
    case 4:	printf("\n\nQuitting in 3 seconds\n");
    						sleep(3000);
    						exit(0);
    							break;
    default: printf("Wrong Choice. Enter again\n");
    							break;
    			}    
      
    		} while (choice != 4);
    }
     
    int Not(int x)
    {
        return !x;
    }
     
    int And(int x, int y)
    {
        return x && y;
    }
     
    int Or(int x, int y)
    {
        return x || y;
    }
    
    
    int Xor (int x, int y)
    {
    	if (x==0 && y==0)
    return 0;
    	if (x==0 && y==1)
    return 1;
    	if (x==1 && y==0)
    return 1;
    	if (x==1 && y==1)
    return 0;
    }
    int Xnor (int x, int y)
    {
    	if (x==0 && y==0)
    return 1;
    	if (x==0 && y==1)
    return 0;
    	if (x==1 && y==0)
    return 0;
    	if (x==1 && y==1)
    return 1;
    }
    int Nand (int x, int y)
    {
    	if (x==0 && y==0)
    return 1;
    	if (x==0 && y==1)
    return 1;
    	if (x==1 && y==0)
    return 1;
    	if (x==1 && y==1)
    return 0;
    }
    int Nor (int x, int y)
    {
    	if (x==0 && y==0)
    return 1;
    	if (x==0 && y==1)
    return 0;
    	if (x==1 && y==0)
    return 0;
    	if (x==1 && y==1)
    return 0;
    }
    //MULTIPLEXER
    int multiplexer(int a, int b, int c)
    {
        return Or((And(a, (Not (c)))), (And(b, c)));
    }
    //FULL ADDER
    int full_adder_sum(int a, int b, int c)
    {
    	return Xor(a, (Xor(b, c)));
    }
    int full_adder_carry(int a, int b, int c)
    {
    	return Or((And(a, b)), (And(c, (Or(a, b)))));
    }
    //FULL ADDER WITH EXTRA CARRY
    int full_adder_extra_carry(int a, int b, int full_adder_carry)
    {
    	return Or((And(a, b)), (And(full_adder_carry, (Or(a, b)))));
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu choice question
    By Thegame16 in forum C Programming
    Replies: 4
    Last Post: 11-21-2010, 10:35 PM
  2. Need help making a choice
    By PJYelton in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 01-09-2003, 04:05 PM
  3. How to modify a menu into a menu Folder(contains submenus) ??
    By L.O.K. in forum Windows Programming
    Replies: 3
    Last Post: 01-09-2003, 02:26 PM
  4. Choice function
    By Pr0gY in forum C Programming
    Replies: 1
    Last Post: 04-18-2002, 08:08 PM
  5. Os of Choice
    By Fordy in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 09-26-2001, 08:27 AM