C Saved Program: quiescent-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()
{
int x[100];
int n1,n2,fact=1,k=0,count=0,i,j,no,t,count2=0,e=0,f=0,g=0,h=0,l=0,length=0;
char a[10][10]={"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};


char b[10][10]={"ELEVEN","TWELVE","THIRTEEN","FOURTEEN","FIFTEEN","SIXTEEN",


"SEVENTEEN","EIGHTEEN","NINTEEN"};


char c[10][10]={"TEN","TWENTY","THIRTY","FOURTY","FIFTY","SIXTY","SEVENTY",


"EIGHTY","NINTY"};
char str1,str2,stra,strb,strc,strd,stre,str;



scanf("%d",&n1);
scanf("%d",&n2);
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);e=strlen(stra);
  
 }
 if(no>100)
 {
  t=no/100;
  no=no%100;str1=a[t-1];str2=HUNDRED AND;strb=strcat(str1,str2);f=strlen(strb);

 }
 if(no>=10 && no<20)
 {
  t=no/10;strc=b[t-1];g=strlen(strc);
  
 }
 if(no>19 && no<=100)
 {
  t=no/10;
  no=no%10;
  strd=c[t-1];h=strlen(strd);
 }
 if(no<10)
 {
  stre=a[no-1];l=strlen(stre);
 }
 
}
length=e+f+g+h+l;
for(i=0;i<count;i++)
{
 if(length==x[i])
 {
     count2++;
 }
}
}

}printf("%d",count2);

return 0;
}
Execute

Output

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

Inputs