Syntax Error Before ';' Token

This is a discussion on Syntax Error Before ';' Token within the C Programming forums, part of the General Programming Boards category; Hi, I'm learning C Basics, Here's my code : Code: // This program finds the monthly installment #include <stdio.h> #include ...

  1. #1
    Registered User subhadeepgayen's Avatar
    Join Date
    Jul 2010
    Posts
    9

    Syntax Error Before ';' Token

    Hi,

    I'm learning C Basics,

    Here's my code :

    Code:
    // This program finds the monthly installment
    #include <stdio.h>
    #include <math.h>
    
    int main(void){
        float P,Rpct,R,M;
        int N;
        printf("\nEnter: Principal, Rate%, No. of yrs.\n");
        scanf("%f %f %i",&P,&Rpct,&N);
        R = Rpct/100;
        M = P*R*pow(1+R,N)/(12*(pow(1+R,N)-1);
        printf("\n$%1.2f,@%11.2f%% costs $%1.2f over %i years",P,Rpct,M,N);
        printf("\nPayments will total $%1.2f",12*M*N);
        return 0;
    }
    I get the following error in DEV C++ : http://lookpic.com/d2/i2/1655/KFnQys1y.gif

    Can anyone shed some light on it??

  2. #2
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    You where missing closing braket at the end

    Code:
    M = P*R*pow(1+R,N)/(12*(pow(1+R,N)-1));
    ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  3. #3
    Registered User subhadeepgayen's Avatar
    Join Date
    Jul 2010
    Posts
    9
    oops...so silly of me., thanks for ur time

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    Better variable names wouldn't be a bad idea, either.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Also:

    Code:
    printf("\nEnter: Principal, Rate%%, No. of yrs.\n");

  6. #6
    Registered User
    Join Date
    Jun 2010
    Posts
    45
    you should check if your editor has a "highlight matching bracket" option, its useful in these types of situations. some editors will also add a matching bracket automatically for you, so if you type '(' then the ')' will just appear at the same time so you dont have to remember it

  7. #7
    Registered User subhadeepgayen's Avatar
    Join Date
    Jul 2010
    Posts
    9
    @kermit The double %% is deliberate to print % at the output

    @LordPc i'm using DevC++ can you link to some free or cheap editor? thanks

  8. #8
    Registered User subhadeepgayen's Avatar
    Join Date
    Jul 2010
    Posts
    9
    I do have anather non working program if anyone can help , i have tried it from book illustrating C,

    Code:
    // Character counting small program
    #include <stdio.h>
    
    void main(void){
        int count=0; char ch;
        for (;;){
            ch = getc(stdin);
            if(ch='\n'){
            break;
            }
            else{
            ++count;
            }
        }
        printf("\nEntry has %i chars",count); 
        getch(); 
    }
    whatever i enter it displays 0 count, how can i make it work or is something wrong with it?

    Thanks

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,022
    Quote Originally Posted by subhadeepgayen View Post
    @kermit The double %% is deliberate to print % at the output

    @LordPc i'm using DevC++ can you link to some free or cheap editor? thanks
    Visual Studio and Code::Blocks are popular IDEs.

    Quote Originally Posted by subhadeepgayen View Post
    I do have anather non working program if anyone can help , i have tried it from book illustrating C,

    Code:
    // Character counting small program
    #include <stdio.h>
    
    void main(void){
        int count=0; char ch;
        for (;;){
            ch = getc(stdin);
            if(ch='\n'){
            break;
            }
            else{
            ++count;
            }
        }
        printf("\nEntry has %i chars",count); 
        getch(); 
    }
    whatever i enter it displays 0 count, how can i make it work or is something wrong with it?

    Thanks
    void main should be int main, and the other red part is assignment and not comparison (= vs ==).
    The indentation also needs to be improved.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User subhadeepgayen's Avatar
    Join Date
    Jul 2010
    Posts
    9
    @elysia

    Thanks very much its working now

    i really need some code highlighting editor, its very difficult to distinguish codes as i'm C n00b , i'll try Visual Studio or CB today

  11. #11
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Quote Originally Posted by subhadeepgayen View Post
    @kermit The double %% is deliberate to print % at the output
    Yes, I am aware of that - if you look at the code you posted, it does not have it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 04:01 PM
  2. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 09:26 AM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

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