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 1108009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:01:05+00:00 2026-05-17T02:01:05+00:00

int main() { int x=5,y=10,z=15; printf(%d %d %d); return 0; } Output: 15 10

  • 0
int main()
{
  int x=5,y=10,z=15;
  printf("%d %d %d");
  return 0;
}

Output: 15 10 5 //In Turbo C 4.5

    3 Garbage values in gcc compiler

My teacher told me when we define the variables like int x=5,y=10,z=15; they are by default taken as auto type and stored in stack.When you try print 3 integer values without using their names by printf(), it will print those 3 values in LIFO format as Turbo C compiler does.
But what I think when we define 3 integer variables, they may not be stored in continuous memory locations.So when I try to print 3 integer values without using their names, the compiler will print any three values from top of the stack.so the output will come 3 garbage values as in gcc..

  • 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-05-17T02:01:06+00:00Added an answer on May 17, 2026 at 2:01 am

    This code just shows that Turbo C is poor at optimizing code and puts everything on the stack, while gcc is more aggressive and keeps it in registers or throws it away all together because these three variables have no purpose.

    Anyway, calling printf with a pattern that requires three arguments without providing these arguments, is a mistake.

    Update:

    As an explanation: I’m assuming that printf() will always take its argument from the stack since it’s a function with a variable argument list. Or does anybody know any other calling convention for functions like printf()? Futhermore, I’m assuming there’s no need to put anything else on the stack as there are no other variables. So this mistaken call of printf will print whatever is on top of the stack in main(). But there might be other architectures and calling conventions where my assumpations don’t hold.

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

Sidebar

Related Questions

This code #include <stdio.h> #include <stdlib.h> #include <time.h> int main () { printf (First
Why is there a difference in the output produced when the code is compiled
What does malloc(0) return? Would the answer be same for realloc(malloc(0),0) ? #include<stdio.h> #include<malloc.h>
For this code: #include<stdio.h> void hello() { printf(hello\n); } void bye() { printf(bye\n); }
I was under the impression that this code #include <windows.h> #include <stdio.h> int WINAPI
I have a Perl program and a C program. I want to run the
I am confused about getchar() 's role in the following code. I mean I
can anyone tell my what does the #pragma can do in the c language
After adding the /TSAWARE linker flag to one of my projects (Visual Studio 6),
I am unable to print the euro symbol. The program I am using is

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.