Ticker

6/recent/ticker-posts

Program to Calculate Alpabatical Value of Numeric value using function in c(Nabin timsina)

 #include<stdio.h>

#include<conio.h>

int one_ten(long int);

int ten_twenty(long int);

int twenty_hundred(long int);

int hundred_thousand(long int);

int thousand_tenthousand(long int);

int eleventhousand_twentythousand(long int);

int twentythousand_lakh(long int);

int lakh_tenlakh(long int);

int tenlakh_twentylakh(long int);

int twentylakh_crore(long int);

void main(){

long int num;

printf("Enter a number : ");

scanf("%ld",&num);

if(num==0)

printf("zero");

else if(num>0 &&num<=10)

one_ten(num);

else if(num>10 &&num<20)

ten_twenty(num);

else if(num>=20 && num<100)

twenty_hundred(num);

else if(num>=100 && num<1000)

hundred_thousand(num);

else if(num>=1000 && num<11000)

thousand_tenthousand(num);

else if(num>=11000 && num<20000)

eleventhousand_twentythousand(num);

else if(num>=20000 && num<100000)

twentythousand_lakh(num);

else if(num>=100000 && num<=1000000)

lakh_tenlakh(num);

else if(num>1000000 && num<2000000)

tenlakh_twentylakh(num);

else if(num>=2000000 && num<10000000)

twentylakh_crore(num);

else

printf("invalid");

getch();

}



int one_ten(long int x){

switch(x){

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;

case 10:

printf("ten");

break;

default:

printf(" ");

break;

}

return 0;

}


int ten_twenty(long int x){

int R=x%10;

switch(R){

case 1:

printf("Eleven");

break;

case 2:

printf("twelve");

break;

case 3:

printf("thirteen");

break;

case 4:

printf("fourteen");

break;

case 5:

printf("fifteen");

break;

case 6:

printf("sixteen");

break;

case 7:

printf("seventeen");

break;

case 8:

printf("eighteen");

break;

case 9:

printf("nineteen");

break;

default:

printf(" ");

break;

}

return 0;

}


int twenty_hundred(long int x){

int Q=x/10,R=x%10;

switch(Q){


case 2:

printf("twenty ");

break;

case 3:

printf("thirty ");

break;

case 4:

printf("fourty ");

break;

case 5:

printf("fifty ");

break;

case 6:

printf("sixty ");

break;

case 7:

printf("seventy ");

break;

case 8:

printf("eighty ");

break;

case 9:

printf("ninety ");

break;

default:

printf(" ");

break;

}



one_ten(R);

return 0;

}

int hundred_thousand(long int x){

int Q=x/100,R=x%100;

switch(Q){

case 1:

printf("one hundred ");

break;

case 2:

printf("two hundred ");

break;

case 3:

printf("three hundred ");

break;

case 4: 

printf("four hundred ");

break;

case 5:

printf("five hundred ");

break;

case 6:

printf("six hundred ");

break;

case 7:

printf("seven hundred ");

break;

case 8:

printf("eight hundred ");

break;

case 9:

printf("nine hundred ");

break;



default:

printf(" ");

break;

}

if(R>0 && R<=10)

one_ten(R);

else if(R>10 && R<20)

ten_twenty(R);

else

twenty_hundred(R);

return 0;

}

int thousand_tenthousand(long int x){

int Q=x/1000,R=x%1000;

switch(Q){

case 1:

printf("one thousand ");

break;

case 2:

printf("two thousand ");

break;

case 3:

printf("three thousand ");

break;

case 4:

printf("four thousand ");

break;

case 5:

printf("five thousand ");

break;

case 6:

printf("six thousand ");

break;

case 7:

printf("seven thousand ");

break;

case 8:

printf("eight thousand ");

break;

case 9:

printf("nine thousand ");

break;

case 10:

printf("ten thousand ");

break;

default:

printf(" ");

break;

}

  if(R>0 && R<=10)

one_ten(R);

else if(R>10 && R<20)

ten_twenty(R);

else if(R>20 &&R<100)

twenty_hundred(R);

else if(R>100 && R<1000)

hundred_thousand(R);

else

printf("");

}


int eleventhousand_twentythousand(long int x){

int Y,R,n;

R=x%1000;

  n=x/1000;

Y=n%10;

switch(Y){

case 1:

printf("Eleven thousand ");

break;

case 2:

printf("twelve thousand ");

break;

case 3:

printf("thirteen thousand ");

break;

case 4:

printf("fourteen thousand ");

break;

case 5:

printf("fifteen thousand ");

break;

case 6:

printf("sixteen thousand ");

break;

case 7:

printf("seventeen thousand ");

break;

case 8:

printf("eighteen thousand ");

break;

case 9:

printf("nineteen thousand ");

break;

default:

printf(" ");

break;

}

  if(R>0 && R<=10)

one_ten(R);

else if(R>10 && R<20)

ten_twenty(R);

    else if(R>20 &&R<100)

twenty_hundred(R);

else if(R>100 && R<1000)

hundred_thousand(R);

else

printf("");


return 0;

}


int twentythousand_lakh(long int x){

int Q=x/10000,R=x%1000;

switch(Q){


case 2:

printf("twenty thousand ");

break;

case 3:

printf("thirty thousand ");

break;

case 4:

printf("fourty thousand ");

break;

case 5:

printf("fifty thousand ");

break;

case 6:

printf("sixty thousand ");

break;

case 7:

printf("seventy thousand ");

break;

case 8:

printf("eighty thousand ");

break;

case 9:

printf("ninety thousand ");

break;

default:

printf(" ");

break;

}

  if(R>0 && R<=10)

one_ten(R);

else if(R>10 && R<20)

ten_twenty(R);

    else if(R>20 &&R<100)

twenty_hundred(R);

else if(R>100 && R<1000)

hundred_thousand(R);

else

printf("");

}


int lakh_tenlakh(long int x){

int Q=x/100000,R=x%100000;

switch(Q){

case 1:

printf("one lakh ");

break;

case 2:

printf("two lakh ");

break;

case 3:

printf("three lakh ");

break;

case 4:

printf("four lakh ");

break;

case 5:

printf("five lakh ");

break;

case 6:

printf("six lakh ");

break;

case 7:

printf("seven lakh ");

break;

case 8:

printf("eight lakh ");

break;

case 9:

printf("nine lakh ");

break;

case 10:

printf("ten lakh ");

break;

default:

printf(" ");

break;

}

  if(R>0 && R<=10)

one_ten(R);

else if(R>10 && R<20)

ten_twenty(R);

else if(R>20 &&R<100)

twenty_hundred(R);

else if(R>100 && R<1000)

hundred_thousand(R);

else if(R>=1000 && R<=10000)

thousand_tenthousand(R);

else if(R>=11000 && R<20000)

eleventhousand_twentythousand(R);

else if(R>=20000 && R<100000)

twentythousand_lakh(R);

else

printf("");

}


int tenlakh_twentylakh(long int x){

int Y,R,n;

R=x%100000;

  n=x/100000;

Y=n%10;

switch(Y){

case 1:

printf("Eleven lakh ");

break;

case 2:

printf("twelve lakh ");

break;

case 3:

printf("thirteen lakh ");

break;

case 4:

printf("fourteen lakh ");

break;

case 5:

printf("fifteen lakh ");

break;

case 6:

printf("sixteen lakh ");

break;

case 7:

printf("seventeen lakh ");

break;

case 8:

printf("eighteen lakh ");

break;

case 9:

printf("nineteen lakh ");

break;

default:

printf(" ");

break;

}

 

  if(R>0 && R<=10)

one_ten(R);

else if(R>10 && R<20)

ten_twenty(R);

else if(R>20 &&R<100)

twenty_hundred(R);

else if(R>100 && R<1000)

hundred_thousand(R);

else if(R>=1000 && R<=10000)

thousand_tenthousand(R);

else if(R>=11000 && R<20000)

eleventhousand_twentythousand(R);

else if(R>=20000 && R<100000)

twentythousand_lakh(R);

else

printf("");

return 0;

}


int twentylakh_crore(long int x){

int Q=x/1000000,R=x%100000;

switch(Q){


case 2:

printf("twenty lakh ");

break;

case 3:

printf("thirty lakh ");

break;

case 4:

printf("fourty lakh ");

break;

case 5:

printf("fifty lakh ");

break;

case 6:

printf("sixty lakh ");

break;

case 7:

printf("seventy lakh ");

break;

case 8:

printf("eighty lakh ");

break;

case 9:

printf("ninety lakh ");

break;

default:

printf(" ");

break;

}

  if(R>0 && R<=10)

one_ten(R);

else if(R>10 && R<20)

ten_twenty(R);

else if(R>20 &&R<100)

twenty_hundred(R);

else if(R>100 && R<1000)

hundred_thousand(R);

else if(R>=1000 && R<=10000)

thousand_tenthousand(R);

else if(R>=11000 && R<20000)

eleventhousand_twentythousand(R);

else if(R>=20000 && R<100000)

twentythousand_lakh(R);

else

printf("");


 return 0;

}




Reactions

Post a Comment

0 Comments