Thread: first year college student needs help!

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    3

    first year college student needs help!

    i have an assignment to complete and i'm stuck on some of the code. i've talked to collegues. they say nothings wrong with the logic, just the syntax, but they can't fix it. can anyone help?!

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    i've talked to collegues. they say nothings wrong with the logic
    HaHa -- blind leading the blind.


    Code:
    				if 
    					(correctans=answer)
    					printf("Correct.");
    				    counter1++;
    				else
    					{
    needs a few more braces -- and better coding style. Use == instead of = when boolean operator is intended.
    Code:
    				if (correctans == answer)
    				{
    					printf("Correct.");
    				    counter1++;
    				}
    				else
    				{
    					if(correctans != answer) 
    					{
    					    printf("That is not correct, please try again.");
    					    printf("\n\t\t\tWhat is %d times %d?: ",num,counter);
    						scanf("%d",&answer);
    					    correctans=num*counter;
    					}
    Last edited by Ancient Dragon; 01-16-2006 at 09:37 AM.

  3. #3
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    >>main()
    Main returns an int

    >>printf("\t\tYou have selected the %d times able.",num);
    Being picky I know, but typo, should be table

    >>if (correctans=answer)
    That should be == when testing for equality; same problem on line 53

    Your indentation is a bit all over the place which'll make it harder to follow; as far as I can see there's nothing wrong with the logic (I just scanned through the syntax, however).

    EDIT: Damn you AD!
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    That looks like C code not C++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 02:20 PM
  2. Calendar Problem
    By wordup in forum C Programming
    Replies: 7
    Last Post: 10-29-2002, 03:36 PM
  3. error with code
    By duffy in forum C Programming
    Replies: 8
    Last Post: 10-22-2002, 09:45 PM
  4. cant get code to work
    By duffy in forum C Programming
    Replies: 13
    Last Post: 10-20-2002, 05:23 AM
  5. Simplified code
    By soonerfan in forum C Programming
    Replies: 2
    Last Post: 12-05-2001, 03:50 PM