C Saved Program: serene-dog

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


 
 #include<stdio.h>
#include<string.h>
int main()
{
char x[100];
int n1,n2,fact=1,k=0,count=0,i,j,no,t,count2=0,length=0;
char *a[10]={"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};
char *b[10]={"ELEVEN","TWELVE","THIRTEEN","FOURTEEN","FIFTEEN","SIXTEEN",
"SEVENTEEN","EIGHTEEN","NINTEEN"};
char *c[10]={"TEN","TWENTY","THIRTY","FOURTY","FIFTY","SIXTY","SEVENTY",
"EIGHTY","NINTY"};
char str1[18],str2[18],stra[18],strb[18],strc[18],strd[18],stre[18],str[18];
scanf("%d",&n1);
scanf("%d",&n2);
if(n2<9999)
{
for(i=n1;i<=n2;i++)
{
for(j=2;j<=n1;j++)
{
if(i%j==0)
  fact++;
}
if(fact==2)
{
x[k]=i;
k++;count++;
}
}
for(k=0;k<count;k++)
{
no=a[k];
if(no<9999)
{
 if(no>1000)
 {
  t=no/1000;
  no=no%1000;str1=a[t-1];str2=THOUSAND ;stra=strcat(str1,str2);length=strlen(stra);
  }
 if(no>100)
 {
  t=no/100;
  no=no%100;str1=a[t-1];str2=HUNDRED AND;strb=strcat(str1,str2);length=strlen(strb);
}
 if(no>=10 && no<20)
 {
  t=no/10;strc=b[t-1];length=strlen(strc);
  
 }
 if(no>19 && no<=100)
 {
  t=no/10;
  no=no%10;
  strd=c[t-1];length=strlen(strd);
 }
 if(no<10)
 {
  stre=a[no-1];length=strlen(stre);
 }
 
}

for(i=0;i<count;i++)
{
 if(length==x[i])
 {
     count2++;
 }
}
}
printf("%d",count2);

}
else
printf("invalid");

return 0;
}

Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs