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

create a C program that displays one z,two y's,three x's until twenty six A's. plzz answer i need it tomorrow.

4 Answers  


There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side? Upload a C program to demonstrate the behaviour of the game.

2 Answers  


whats the use of header file in c?

2 Answers  


How do you print an address?

0 Answers   TCS,


can we store values and addresses in the same array? explain

3 Answers   TCS,






What are the types of arrays in c?

0 Answers  


#define min((a),(b)) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i);}

3 Answers  


what does data structure mean?

8 Answers  


What is the size of structure in c?

0 Answers  


What is the purpose of sprintf?

0 Answers  


What is the purpose of 'register' keyword in c language?

0 Answers  


SRUCTURE PROGRAMMING

3 Answers   CTS, Wipro,


Categories