Programming error

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

    #1

    Programming error

    I'm a newbie to programming and am doing this project using linux and an error message keeps popping up and i've tried everything but cannot get it fixed and compiled. Please help, its due today!

    Program is:

    [code=c] /**
    File name: Lab 03;
    Name: George Michael;
    Date: 3/21/08;
    Purpose: To learn how to compile;
    **/



    #include<stdio. h>


    {
    (int my_age; /* users age */);



    printf("wlcome to lab03, we will learn how to compile today \n");
    printf("Enter your age: ");
    scanf("%d";"&my _age");
    Printf("your age is %d","\n,my_age" );


    return0;

    }[/code]


    The error that keeps coming up is:
    Lab03.c:13: error: expected identifier or '(' before '{' token

    I've tried everything from looking at my syntax to adding "('' and semicolons everywhere, but nothing helped. Please help. Thank you very much.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    [code=c]
    int main() //this should be there...or else where is the function name
    {
    (int my_age; /* users age */); ///You cant declare like this. it should be int my_age;



    printf("wlcome to lab03, we will learn how to compile today \n");
    printf("Enter your age: ");
    scanf("%d";"&my _age");
    Printf("your age is %d","\n,my_age" );//This is a problem chage P to lower case printf
    return0;
    }
    [/code]

    Comment

    • Sreeramu
      New Member
      • Apr 2007
      • 11

      #3
      The errors are in printf and scanf check it out and for all the program main function should be there ...
      Code:
      #include<stdio.h>
      int main()
      {
      int my_age; /* users age */
      printf("wlcome to lab03, we will learn how to compile today \n");
      printf("Enter your age: ");
      scanf("%d",&my_age);
      Printf("your age is %d",my_age);
      return 0;
      }
      this code work perfect...

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by Sreeramu
        The errors are in printf and scanf check it out and for all the program main function should be there ...
        Code:
        #include<stdio.h>
        int main()
        {
        int my_age; /* users age */
        printf("wlcome to lab03, we will learn how to compile today \n");
        printf("Enter your age: ");
        scanf("%d",&my_age);
        Printf("your age is %d",my_age);
        return 0;
        }
        this code work perfect...
        That doesn't work. You have an uppercase P for your printf on line 8.
        gp's response is rather sufficient for this.

        Comment

        • marmar12
          New Member
          • Mar 2008
          • 11

          #5
          really really appreciate it guys

          Comment

          Working...