convert 12345 to 54321 withoutusing strig

Answers were Sorted based on User's Feedback



convert 12345 to 54321 withoutusing strig..

Answer / abhradeep chatterjee

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
printf("enter a number");
scanf("%d",&i);
for(int n=1;n<=5;n++)
{
j=i%10;
i=i/10;
printf("%d",j);
}
getch();
}

Is This Answer Correct ?    5 Yes 4 No

convert 12345 to 54321 withoutusing strig..

Answer / pavan kumar b n

By making use of stack data structure.... i.e., first push
all the numbers and then pop them .. since stack is LIFO
order , the numbers get reversed....

Is This Answer Correct ?    1 Yes 0 No

convert 12345 to 54321 withoutusing strig..

Answer / satrughna sethi

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
printf("enter a number");
scanf("%d",&i);
for(int n=1;n<=5;n++)
{
j=i%10;
i=i/10;
printf("%d",j);
}
getch();
}

Is This Answer Correct ?    5 Yes 5 No

convert 12345 to 54321 withoutusing strig..

Answer / ismail

void main()
{
long num, temp;
for(;;) {
printf("Enter number:");
scanf("%ld",&num);
if(num == 0) break;
while(num) {
temp = num%10;
num = num/10;
printf("%ld", temp);
}
printf("\n");
break;
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

convert 12345 to 54321 withoutusing strig..

Answer / mani bhowmik

void main()
{
int num, temp;
for(;;) {
printf("Enter number:");
scanf("%d",&num);
if(num == 0) break;
while(num) {
temp = num%10;
num = num/10;
printf("%d", temp);
}
printf("\n");
}
getche();
}
So any number will be reversed here. 12345 is five digit
number. Using while we can generalize the number of digits.
The continuous loop is ended when 0 is entered.

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More C Interview Questions

a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

0 Answers  


what is the c.

3 Answers   IBM, TCS,


simple program of graphics and thier outpu display with a want what is out put of graohics in c language

1 Answers   CSC, HCL,


what is pointer ? what is the use of pointer?

6 Answers   Infosys,


Famous puzzles which are generally asked by companies during interviews ?

1 Answers   3D PLM, Yahoo,






we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above

0 Answers  


dennis ritchie invented C language in AT&T bell laboratory what is the extension of AT&T?

4 Answers  


How do I copy files?

0 Answers  


when i declare as: void main() { clrscr(); int a=10; printf("%d",a) } my problem that why generate a error in above programs. please tell me answer seriously .

4 Answers  


What is pre-emptive data structure and explain it with example?

0 Answers  


input may any number except 1,output will always 1.. conditions only one variable should be declare,don't use operators,expressions,array,structure

4 Answers   IBM,


how to sort two array of characters and make a new array of characters.

1 Answers   Accenture,


Categories