VB icon

Input integer without enter in turn by pressing space

Email
Submitted on: 3/7/2016 3:26:19 PM
By: Divyanshu Mishra  
Level: Beginner
User Rating: Unrated
Compatibility: C, C++ (general), Microsoft Visual C++, Borland C++
Views: 1983
 
     Ever thought what if you want to just input an Integer without pressing enter, so that you can get next results from the same same line instead of getting pussed to the newline automatically.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Input integer without enter in turn by pressing space
// Description:Ever thought what if you want to just input an Integer without pressing enter, so that you can get next results from the same same line instead of getting pussed to the newline automatically.
// By: Divyanshu Mishra
//**************************************

#include<stdio.h>
#include<conio.h>
#include<math.h>
void printwon(char c1[100],int h);
void divscan(char n[100]);
void main()
{
clrscr();
printf("\n");
char c[100];
printf("Enter an Integer");
divscan(c);
getch();
}
int i,count=0;
void divscan(char n[100])
{
 for(i=0;i<=20;i++)
 {
n[i]=getch();
putch(n[i]);
if(n[i]==' ')
break;
count++;
 }
 printwon(n,count);
}
/*Convert char to integer*/
int count1=0;
void printwon(char c1[100],int h)
{
 int j;
 long int n,n1=0;
 for(j=0;j<=h-1;j++)
 {
n=c1[j];
if(n==48)
{
n=0;
}
else if(n==49)
{
n=pow(10,h-1)/(pow(10,count1));
}
else if(n==50)
{
n=2*(pow(10,h-1)/(pow(10,count1)));
}
else if(n==51)
{
n=3*(pow(10,h-1)/(pow(10,count1)));
}
else if(n==52)
{
n=4*(pow(10,h-1)/(pow(10,count1)));
}
else if(n==53)
{
n=5*(pow(10,h-1)/(pow(10,count1)));
}
else if(n==54)
{
n=6*(pow(10,h-1)/(pow(10,count1)));
}
else if(n==55)
{
n=7*(pow(10,h-1)/(pow(10,count1)));
}
else if(n==56)
{
n=8*(pow(10,h-1)/(pow(10,count1)));
}
else if(n==57)
{
n=9*(pow(10,h-1)/(pow(10,count1)));
}
count1++;
n1=n1+n;
 }
printf("\t%ld",n1);
}


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.