If input is 123 then how to print 100 and 20 and 3 seperately?

Answers were Sorted based on User's Feedback



If input is 123 then how to print 100 and 20 and 3 seperately?..

Answer / letskools

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5];
int i, j,rem,k=0,x=1;
int num;
printf("enter any number");
scanf("%d",&num);
while(num>0)
{
rem = num % 10;
a[k] = rem * x;
x *= 10;
k++;
num /= 10;
}
for (i = k-1; i >= 0; i--)
{
printf("%d\n"a[i]);
}
getch();
}

Is This Answer Correct ?    6 Yes 0 No

If input is 123 then how to print 100 and 20 and 3 seperately?..

Answer / charusheela

#include<stdio.h>
#include<conio.h>
void main(){
int num=123,r,i=1;
clrscr();
while(num)
{
r=num%10;
printf("%d\n",r*i);
i*=10;
num/=10;
}
getch();
}

Is This Answer Correct ?    2 Yes 0 No

If input is 123 then how to print 100 and 20 and 3 seperately?..

Answer / dhruv sharma rkdf

#include<stdio.h>
#include<conio.h>
void main(){
int n,temp,i=1;
clrscr();
printf("enter number:");
scanf("%d",&n);
for(;n>0;n=n/10){
temp=(n%10)*i;
i*=10;
printf("%d\n",temp)
}
getch();
}

Is This Answer Correct ?    1 Yes 0 No

If input is 123 then how to print 100 and 20 and 3 seperately?..

Answer / cute_boy4434

PLz reply me soon . ya

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More C Interview Questions

study the code: #include<stdio.h> void main() { const int a=100; int *p; p=&a; (*p)++; printf("a=%dn(*p)=%dn",a,*p); } What is printed? A)100,101 B)100,100 C)101,101 D)None of the above

15 Answers   Accenture, TCS,


How to find the usage of memory in a c program

1 Answers   Infosys,


1. Write the function int countchtr(char string[ ], int ch); which returns the number of times the character ch appears in the string. Example, the call countchtr(“She lives in NEWYORK”, ‘e’) would return 3.

4 Answers  


swapping of two numbers without using third variable using AND and OR operators

2 Answers  


Write a Program to find whether the given number or string is palindrome.

0 Answers   InterGraph,






Q. where is the below variables stored ? - volatile, static, register

3 Answers   Bosch,


Why the use of alloca() is discouraged?

2 Answers   Oracle,


What is infinite loop?

0 Answers  


why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above

0 Answers  


What is the -> in c?

0 Answers  


How to reverse a string using a recursive function, without swapping or using an extra memory?

31 Answers   Cisco, Mind Tree, Motorola, Ophio, Sony, TCS, Wipro,


Explain the difference between getch() and getche() in c?

0 Answers  


Categories