Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

2. Counting in Lojban, an artificial language developed
over the last fourty years, is easier than in most languages
The numbers from zero to nine are:
0 no
1 pa
2 re
3 ci
4 vo
5 mk
6 xa
7 ze
8 bi
9 so
Larger numbers are created by gluing the digit togather.
For Examle 123 is pareci
Write a program that reads in a lojban string(representing
a no less than or equal to 1,000,000) and output it in
numbers.

Answer Posted / abdur rab

#include <stdio.h>

int decimal_from_logban ( char* cp_logban )
{
if ( !strcmp ( cp_logban, "no" ) ) return 0;
if ( !strcmp ( cp_logban, "pa" ) ) return 1;
if ( !strcmp ( cp_logban, "re" ) ) return 2;
if ( !strcmp ( cp_logban, "ci" ) ) return 3;
if ( !strcmp ( cp_logban, "vo" ) ) return 4;
if ( !strcmp ( cp_logban, "mk" ) ) return 5;
if ( !strcmp ( cp_logban, "xa" ) ) return 6;
if ( !strcmp ( cp_logban, "ze" ) ) return 7;
if ( !strcmp ( cp_logban, "bi" ) ) return 8;
if ( !strcmp ( cp_logban, "so" ) ) return 9;
}

void logban_2_decimal ( char* _lojban, int* _decimal )
{
char lojban_array [3];

memset ( lojban_array, '\0', 3 );
if ( ( NULL != _lojban ) && ( '\0' != *( _lojban +
2 ) ) ) {
logban_2_decimal ( _lojban + 2, _decimal +
1 );
strncpy ( lojban_array, _lojban, 2 );
*_decimal = decimal_from_logban (
lojban_array );
} else {
strncpy ( lojban_array, _lojban, 2 );
*_decimal = decimal_from_logban (
lojban_array );
}

}

int main ( int argc, char* argv [] )
{
char number_lojban [] = {"sopareci"};
int number_decimal [8];
int i = 0;

logban_2_decimal ( number_lojban, number_decimal ) ;
printf ( "\nLojban :%s", number_lojban );

printf ( "\nDecimal :" );
for ( i = 0; i < ( strlen ( number_lojban ) / 2 );
i++ )
printf ("%d", number_decimal [ i ] );

return ( 0 );
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you understand by friend-functions? How are they used?

1192


How can I find out if there are characters available for reading?

1102


Explain that why C is procedural?

1127


Explain how do you override a defined macro?

1054


Between macros and functions,which is better to use and why?

2195


How does pointer work in c?

1109


How to delete a node from linked list w/o using collectons?

2767


How do you determine whether to use a stream function or a low-level function?

1111


Why does the call char scanf work?

1184


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

1220


What is the size of structure pointer in c?

1052


What is the difference between exit() and _exit() function?

1024


What is the symbol indicated the c-preprocessor?

1227


How do you construct an increment statement or decrement statement in C?

1213


#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

1137