Error: printf statement should contain prototype

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • goutham1
    New Member
    • May 2007
    • 13

    Error: printf statement should contain prototype

    hai can any body help me iam starting my c programming.
    i started my basic programme that is adding two numbers
    when i compiled my programme in cpp in the print f statement it is telling printf statement should contain prototype can any body please help me
  • DeMan
    Top Contributor
    • Nov 2006
    • 1799

    #2
    assuming you are including stdio.h, it sounds like you have a slight syntax error (specifically the way you are trying to display the output is not quite correct. It should probably look something like this (I am assuming integer addition here)
    Code:
    printf("Sum of %d and %d is %d", a, b, (a+b));

    Comment

    • goutham1
      New Member
      • May 2007
      • 13

      #3
      Originally posted by DeMan
      assuming you are including stdio.h, it sounds like you have a slight syntax error (specifically the way you are trying to display the output is not quite correct. It should probably look something like this (I am assuming integer addition here)
      Code:
      printf("Sum of %d and %d is %d", a, b, (a+b));
      my programme is like this
      main( )
      {
      int a,b,c;
      a=5;b=6;
      c=a+b;
      printf("%d",c);
      }

      ihad changed it and seen the programme but the same error it is sowing
      please help me
      again it shows the msg like printf should have a prototype.

      Comment

      • Ganon11
        Recognized Expert Specialist
        • Oct 2006
        • 3651

        #4
        You are probably not including the proper header file. Before you type main(), type the following line:

        Code:
        #include <stdio.h>
        If you are compiling this as a C++ program, make sure you change the file name to .C so that you will compile this as a C program.

        Comment

        • svlsr2000
          Recognized Expert New Member
          • Feb 2007
          • 181

          #5
          All standard functions are declared in header files provided along with your compiler. these declarations provide the necessary prototypes while compiling.

          Comment

          Working...