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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:21:49+00:00 2026-05-23T14:21:49+00:00

I would like to know Where arugment passed to main() gets stored in memory

  • 0

I would like to know Where arugment passed to main() gets stored in memory ,Do they simply get store in stack .If so then how k’s value is initialize in below code

 #include<stdio.h>
 int main(int k)
 {
 if(k<10)
 printf("%d ",main(k+1));
 return k;
 }

O/p: 10 9 8 7 6 5 4 3 2 
  • 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-23T14:21:50+00:00Added an answer on May 23, 2026 at 2:21 pm

    It’ll typically be stored wherever parameters to other functions get stored — which might be stack, register, or somewhere else entirely. Just for a few examples: on a SPARC, it’ll almost certainly be a register; on an x86 (in 32-bit mode) it’ll typically be the stack; on an IBM mainframe, it’ll normally be in a stack frame that’s dynamically allocated from the heap and linked together into a linked list that’s constructed/destroyed FIFO fashion.

    Also note that it can/does vary even on a single machine with a single compiler — e.g., Microsoft VC++ can pass it on the stack or in a register depending on what compiler flag(s) you use. When/if you pass it in a register, it’ll (probably) be pushed on the stack inside the function anyway (to allow the recursion).

    As an aside, I’ll also note that while your codecalling main is perfectly legal C, you are not allowed to call main in C++.

    Edit: As for the initial value, that first parameter is traditionally called argc, and tells you how many arguments were passed on the command line. If you invoke it (as you apparently have) with no command line, it should normally start out as 1 (the one argument being the name of the program itself, traditionally passed as argv[0]). If, for example, you invoked the program something like:

    prog a b c d e f g h i j k l m
    

    It would normally exit without printing anything, because on the first entry to main, the parameter would be greater than 10 so the body of the if statement would never execute.

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

Sidebar

Related Questions

I would like to know how to pass single quotations as an argument in
i would like know some reference. I know i can googling it. but prefer
Would like to know what a programmer should know to become a good at
Would like to know the c# code to actually retrieve the IP type: Static
Would like to know how to integarate cruise control with maven? Cruise Control comes
Would like to know how to hide an div after a set of css3
I would like to know when my WebView has finished loading a page. Im
I would like to know if I can open 2 different diagrams using MS
I would like to know which dependency described in my pom.xml brings a transitive
I would like to know what semaphores, messageQueues, etc... are active in my vxWorks

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.