Given only putchar (no sprintf, itoa, etc.) write a routine
putlong that prints out an unsigned long in decimal.

Answer Posted / rakesh

void main()
{
unsigned long n;
int i;
void putlong(unsigned long);
cout<<"\nEnter the number::";
cin>>n;
putlong(n);
}

void putlong(unsigned long n)
{
if(n==0)
return;
print(n/10);
putchar((n%10) + 48);

}

Is This Answer Correct ?    2 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

2402


How to palindrom string in c language?

8832


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

2857


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

1768


How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.

1928






How can you relate the function with the structure? Explain with an appropriate example.

2915


What is full form of PEPSI

1862


#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1067


What is data _null_? ,Explain with code when u need to use it in data step programming ?

2820


What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?

3706


Cluster head selection in Wireless Sensor Network using C programming language.

3107


could you please send the program code for multiplying sparse matrix in c????

3067


how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

3117


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2325


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2258