Program:
#include<stdio.h>
#include<string.h>
//#include<conio.h>
void main()
{
int b,c,d,i=0,j,k,r;char a[100];int x[100];
// clrscr();
printf("Enter the number:");
scanf("%s",a);
c=strlen(a);
b=atoi(a);
//printf("no.=%d\n",b);
while(b!=0)
{
r=b%10;
x[i]=r;
i++;
b=b/10;
}
if(c!=i)
{
d=c-i;
for(k=0;k<d;k++)
printf("Zero");
}
for(j=i-1;j>=0;j--)
{
switch(x[j])
{
case 0: printf("Zero");
break;
case 1: printf("One");
break;
case 2: printf("Two");
break;
case 3: printf("Three");
break;
case 4: printf("Four");
break;
case 5: printf("Five");
break;
case 6: printf("Six");
break;
case 7: printf("Seven");
break;
case 8: printf("Eight");
break;
case 9: printf("Nine");
break;
}
}
printf("\n");
//getch();
}
Output:
nn@linuxmint ~ $ gcc c23.c
nn@linuxmint ~ $ ./a.out
Enter the number:101
OneZeroOne
nn@linuxmint ~ $
#include<stdio.h>
#include<string.h>
//#include<conio.h>
void main()
{
int b,c,d,i=0,j,k,r;char a[100];int x[100];
// clrscr();
printf("Enter the number:");
scanf("%s",a);
c=strlen(a);
b=atoi(a);
//printf("no.=%d\n",b);
while(b!=0)
{
r=b%10;
x[i]=r;
i++;
b=b/10;
}
if(c!=i)
{
d=c-i;
for(k=0;k<d;k++)
printf("Zero");
}
for(j=i-1;j>=0;j--)
{
switch(x[j])
{
case 0: printf("Zero");
break;
case 1: printf("One");
break;
case 2: printf("Two");
break;
case 3: printf("Three");
break;
case 4: printf("Four");
break;
case 5: printf("Five");
break;
case 6: printf("Six");
break;
case 7: printf("Seven");
break;
case 8: printf("Eight");
break;
case 9: printf("Nine");
break;
}
}
printf("\n");
//getch();
}
Output:
nn@linuxmint ~ $ gcc c23.c
nn@linuxmint ~ $ ./a.out
Enter the number:101
OneZeroOne
nn@linuxmint ~ $
Join our Best Mern Stack Course In South Delhi and gain a holistic understanding of full-stack web development through the MERN technology stack. Position yourself as a proficient web developer in the competitive industry.
ReplyDelete