Thread: What output does it produce?

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    7

    What output does it produce?

    I am trying to find how do I find what output does it produce?

    Code:
      
    int funA(intx);
    
    int main()
    {
    
    int a,b,c;
         a=5;
         b=5;
         c= funA(b);
         printf(%d %d %d,a,b,c);
         return 0;
    
    }
    
    int funA(int m)
    {      return m*m;
    }
    When I entered the following information in the complier nothing happens. Should I not enter the following code in the complier
    Last edited by intimidator; 04-23-2011 at 02:42 PM.

  2. #2
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    463
    no compiler will compile that code for you. where are the semicolons? and how about including some header file for printf?
    "All that we see or seem
    Is but a dream within a dream." - Poe

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    7
    My mistake I forgot the semicolons but, with the semicolons it will not compile

  4. #4
    Registered User
    Join Date
    Apr 2011
    Location
    Las Vegas
    Posts
    66
    Programming languages like C have formal and very specific grammars. If you make any mistakes in the source code, the program will not compile. (As compared to human languages where we "get" what someone is trying to say, even though it may not be grammatically correct!)

    You have three mistakes you need to address. The first is the failure to include a required library for the printf statement. The second is the argument in the funA prototype. And the third is the printf statement - the format string needs to be enclosed in quotes.

    Having said all that, you should be able to "bench test" the program and step through it yourself and find the answer you're looking for!

    Kevin

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by intimidator View Post
    I am trying to find how do I find what output does it produce?
    "Syntax error"

  6. #6
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Code:
    int funA(int x);
    
    int main()
    {
    
    int a,b,c;
         a=5;
         b=5;
         c= funA(b);
         printf("%d %d %d\n",a,b,c);
    
     return 0;   
    }    
    int funA(int m)
    {      
    return m*m;
    }
    that should do it

  7. #7
    Registered User
    Join Date
    Mar 2011
    Posts
    7
    When I try to compile the output camel-man posted I would see the black screen pop up but then it goes off screen and nothing happens.

  8. #8
    Registered User
    Join Date
    Apr 2011
    Location
    Las Vegas
    Posts
    66
    Before the end of the main function, add
    Code:
    system("PAUSE");
    Kevin

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to produce sum with int and char
    By quintenmater in forum C Programming
    Replies: 15
    Last Post: 12-06-2010, 01:33 AM
  2. North Carolina's (not so) fresh produce
    By Sebastiani in forum General Discussions
    Replies: 4
    Last Post: 07-01-2009, 11:43 PM
  3. I would like to Produce 2d and 3d plots
    By BobInNJ in forum Windows Programming
    Replies: 2
    Last Post: 03-04-2009, 10:16 PM
  4. Can't Produce a buffer overflow
    By someprogr in forum C Programming
    Replies: 8
    Last Post: 09-15-2008, 08:59 AM
  5. Replies: 3
    Last Post: 01-08-2004, 09:43 PM