By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,374 Members | 1,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,374 IT Pros & Developers. It's quick & easy.

How to Scanf inside loop if it is based on the user input

P: 1
for(int k=1;k<=num;k++)
printf(\nPlease enter your desired seat %i: ",k)
scanf("%i",&a);

//num is declared if how many the user will input
How to use scanf?
Sep 27 '15 #1
Share this Question
Share on Google+
1 Reply


P: 22
You can declare an array of int of enough size like
Expand|Select|Wrap|Line Numbers
  1. int array[100];
  2.  
And use scanf something like
Expand|Select|Wrap|Line Numbers
  1. for(k=0; k < num; k++)
  2. scanf("%d",&array[k])
  3.  
You can loop from k 0 to num-1 instead of 1 to num.
Sep 27 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.