HELP!! Syntax errors

This is a discussion on HELP!! Syntax errors within the C Programming forums, part of the General Programming Boards category; I am trying to compile a simple program and I know there are a bunch of syntax errors. The program ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    1

    HELP!! Syntax errors

    I am trying to compile a simple program and I know there are a bunch of syntax errors.

    The program is designed to output to the used which of the first four prime numbers the number they input is divisible by. Here is the code:
    Code:
    #include(stdio.h>
    int main(){
         int num;
         printf("Please enter your number:);
         scanf("%d",num);
         printf("\n\nOf the first prime numbers, your number is divisible by:");
         If (num%2==0)
         printf("2")
         If (num%3==0)
         printf("3")
         If (num%5==0)
         printf("5")
         If (num%7==0)
         printf("7")
    }
    I get errors about args and pointers. I'm new to this and I don't really know what it means. Can someone help?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    In C all keywords are lower-case, so replace "If" with "if". You are also massively low on semicolons. Add one after each of the printf("<number>")

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Oh, and you want to do scanf("%d", &num)

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 02:29 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. errors syntax
    By bazzano in forum C Programming
    Replies: 2
    Last Post: 09-30-2005, 03:44 AM
  4. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM
  5. Expression/Declaration Syntax Errors
    By fuh in forum C++ Programming
    Replies: 2
    Last Post: 01-15-2003, 06:49 PM

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