Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

Print an integer using only putchar. Try doing it without
using extra storage.

Answers were Sorted based on User's Feedback

Print an integer using only putchar. Try doing it without using extra storage...

void putlong(unsigned long x)
{ if (x > 10) putlong(x / 10);
putchar(x % 10+'0');
}
main()
{
long int a;
printf("enter long integer:");
scanf("%d",&a);
putlong(a);
return 0;

}

 Is This Answer Correct ? 22 Yes 5 No

Print an integer using only putchar. Try doing it without using extra storage...

This can be done by recursion.
Since the number of recursive calls is not significant, it does not affect the performance much

printnumber(int i)
{
if(i == 0)
return;
printnumber(i/10);
putchar(’0&#8242; + i%10);
}

 Is This Answer Correct ? 2 Yes 4 No

More C Code Interview Questions

#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }

Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

Write a routine that prints out a 2-D array in spiral order

write a program in c to merge two array

1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.

Write a c program to search an element in an array using recursion

#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }

respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

What is "far" and "near" pointers in "c"...?

#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }

Categories