Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9139589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:24:26+00:00 2026-06-17T09:24:26+00:00

i read somewhere that printf takes the values of the first two assignments of

  • 0

i read somewhere that
printf takes the values of the first two assignments of the program. Any
number of printf’s may be given. All of them take only the first two
values. If more number of assignments given in the program,then printf
will take garbage values.

i don’t think so but it was given on many websites so just need to confirm it

For example, if you do a simple Google search for "printf takes first two assignment as input" there are sites that have sample interview question/answers such as:

Predict the output or error(s) for the following:

main()
{
    int i=400,j=300;
    printf("%d..%d");
}

Answer: 400..300

Explanation: printf takes the values of the first two assignments of the program. Any number of printf’s may be given.

All of them take only the first two values. If more number of
assignments given in the program,then printf will take garbage values.

Is this the correct true behavior? or is it implementation dependent?

You can find such Q&A places like:
this puzzle site
and this interview question doc

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:24:27+00:00Added an answer on June 17, 2026 at 9:24 am

    No, it’s definitely not true.

    For the context, read C11 7.21.6.3/2:

    The printf function is equivalent to fprintf with the argument stdout interposed
    before the arguments to printf.

    So, from the standard, C11 7.21.6.1/2:

    The fprintf function writes output to the stream pointed to by stream, under control
    of the string pointed to by format that specifies how subsequent arguments are
    converted for output. If there are insufficient arguments for the format, the behavior is
    undefined.
    […]

    (emphasis mine)

    What can possibly happen is that the values from the stack may be pulled by printf() when it’s called. Then again, since behavior is undefined, anything could happen, from printing garbage values or a program crash, to printing out a cake picture on the neighbor’s parallel printer (really, anything).

    Unless your specific implementation (a specific CPU architecture, with a specific compiler and possibly a specific operating system) documents the specific case as being something you can do, don’t do it.

    Your puzzle site’s “puzzles” are mostly a combination of undefined behavior and incorrect assumptions regarding implementation-defined behavior. Some examples are correct, but considering it’s mostly bad, I’d just pretend I never saw it. Random internet sites tend to be a bad resource for learning programming, especially C. If you want to learn C, you should get a proper book on C programming (a list can be found here).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read somewhere that the ?: operator in C is slightly different in C++,
I read somewhere that Pattern Matching like that supported by the match/case feature in
I read somewhere that somebody could access a config value during run time but
I read somewhere that you would never run syncdb on a database, post its
I read somewhere that body temperature can be measured through touch screen since different
I read somewhere that, overriding is the means by which you get polymorphism. Polymorphism
I think I read somewhere that cpu's do some floating point computations in 50
I think I read somewhere that some modules only have object oriented interfaces (
I've read somewhere that <img> element behaves like both. If correct, could someone please
I recall having read somewhere that it is better (in terms of performance) to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.