Thread: some issue about if else function

  1. #1
    Registered User
    Join Date
    Jul 2017
    Posts
    48

    some issue about if else function

    Code:
    void additionlevel1menu()
    {
    
    
        int n1, n2, pcans, userans;
        int count = 1, mark = 0;
    
    
    
    
        do {
            srand((unsigned int)time(NULL));
            n1 = rand() % 10;
            n2 = rand() % 10;
            pcans = n1 + n2;
    
    
            printf("%d.%d+%d>", count, n1, n2);
            scanf("%d", &userans);
            if
            {
                userans == pcans
                    printf("You are right\n");
                mark = mark + 5;
            }
            else
            {
                printf("You are wrong\n");
            }
            count++;
            } while (count <= 3);
        printf("Your score is %d", mark);
    }




    it show 12 error whn i run it...can someone hlp me to fix it?i try but failed

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Code:
            if
            {
                userans == pcans
    should be
    Code:
            if ( userans == pcans ) {
    You had enough examples of doing this right in your other thread.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2017
    Posts
    48
    thank you vry much!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function issue
    By elwad in forum C Programming
    Replies: 5
    Last Post: 09-06-2009, 05:55 AM
  2. Function issue
    By Learner87 in forum C++ Programming
    Replies: 1
    Last Post: 04-09-2008, 01:31 PM
  3. template function issue
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 12-12-2007, 12:39 PM
  4. Function Pass Issue
    By Padawan in forum C Programming
    Replies: 6
    Last Post: 04-05-2004, 01:28 AM
  5. Array and Function issue
    By xdrunkcowx in forum C++ Programming
    Replies: 6
    Last Post: 06-04-2003, 10:51 PM

Tags for this Thread