simple coding error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marmar12
    New Member
    • Mar 2008
    • 11

    simple coding error

    Code:
    #include <stdio.h>
    
    
    int main;
    int max;
    char M,G,R,Q
    int num1
    int num2;
    int base;
    int power;
    
    
    {
    printf("Welcome to Math Helper v0.1, This program is designed to help you wi$
    mulipication, exponents, and finding the greatest common divisor.");
    
    printf("Please choose of the following options \n M=Print a muliplication ta$
    G-Find the Greatest common divisor \n R-Raise a number to a power \n
    Q-quit \n %f  ", char);
    
    scanf("%f  "; &MS);
    
    
    if (MS=M)
    void PrintMultiplicationTable(int max);
    
    if (MS=G)
    int GreatestCommonDivisor(int num1, int num2);
    
    if (MS=R)
    int RaiseToPower(int base, int power);
    
    if (MS=Q)
    exit
    
    
    
    return 0;
    
    }
    given is the code i've worked on and i keep getting the same errors on the same lines even though i've corrected them to my best. Please help and show me where and how i can fix if you can. Thank you.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    If you are getting errors you would like help fixing then you should post the errors you are getting.

    Also if this is your complete code then you are lacking the basic structure for a C (or C++) program, please check you text book for the first program example given in it.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      I don't consider the above C or C++ code; it lacks the basic structure imposed by
      those languages and therefore I don't consider this a 'simple coding error'. Please
      rewrite that gibberish to make it suitable for discussion in a proper C or C++ forum.

      kind regards,

      Jos

      Comment

      • questionit
        Contributor
        • Feb 2007
        • 553

        #4
        Originally posted by marmar12
        Code:
        #include <stdio.h>
        
        
        int main;
        int max;
        char M,G,R,Q
        int num1
        int num2;
        int base;
        int power;
        
        
        {
        printf("Welcome to Math Helper v0.1, This program is designed to help you wi$
        mulipication, exponents, and finding the greatest common divisor.");
        
        printf("Please choose of the following options \n M=Print a muliplication ta$
        G-Find the Greatest common divisor \n R-Raise a number to a power \n
        Q-quit \n %f  ", char);
        
        scanf("%f  "; &MS);
        
        
        if (MS=M)
        void PrintMultiplicationTable(int max);
        
        if (MS=G)
        int GreatestCommonDivisor(int num1, int num2);
        
        if (MS=R)
        int RaiseToPower(int base, int power);
        
        if (MS=Q)
        exit
        
        
        
        return 0;
        
        }
        given is the code i've worked on and i keep getting the same errors on the same lines even though i've corrected them to my best. Please help and show me where and how i can fix if you can. Thank you.

        There are several syntax errors in your program. Use of ';' at incorrect places itself is the cause of errors.
        You have also missed ';' at declaration of the char variables and at declaration of 'num1'

        You are missing main(), without which the program will not run.

        Incorrect syntax is used to check for equality in if().

        C/C++ doesn;t allow to use C/C++ keywords as variable names. Please check your first printf() statement to see the error.

        Also, syntax of scanf() needs your attention.
        Also, you have in the scanf() 'MS', which is not defined in the program.


        Moreover, to call a function, function name is used without a ';' in the end.
        In case of your example, this is a declaration of a function , not a call to it. Function declaration is not permitted in these places where you have them anyway.

        This was just a brief. Please learn more C/C++ and re-write your code and let us know if you get errors again.

        Regards
        Qi

        Comment

        Working...