Simple
c programs

1)

**Factorial**
long Fact ( int n )

{

if ( n>0 )

return( n * Fact (n-1) ); //recursion

else

return( 1 );

}

2)

**GCD**
int GCD( int x, int y ) {

if ( x>=y AND x%y==0 )

return( y );

else if ( x

return( GCD( y, x ) );

else

return( GCD( y, x%y ) );

}

C
programs are the basic building blocks of knowledge, which you can gain by
deeply studying the simple C program examples. Here in this C programming
tutorials on bay-six we will learn by looking at some sample programs in C, which
surely will help you to boost your C programming knowledge. Have a look on
these sample programs in C and enjoy! Stay tuned for more

3)

**Decimals to words**
void DecToWord( int n )

{

char *wordarr[ ] = { "Zero",
"One", "Two", "Three", "Four",

"Five", "Six",
"Seven", "Eight", "Nine" };

if (n>9)

DecToWord ( n/10 );

printf( "%s ", wordarr [n%10] );

}

4)

**Decimal to Binary**
void DecToBin( int n ) /* prints decimal in
binary */

{

if (n>1)

DecToBin ( n/2 );

printf( "%d", n%2 );

}

5)

**Fibonacci**
int Fib ( int n ) /* returns nth Fibonacci
number */

{

if ( n==1 || n==2 )

return( 1 );

else

return( Fib (n-1) + Fib (n-2) ); //Recursion

}

6)

**Decimal to hexadecimal conversion**
void DecToHex( int n ) {

char *numarr[ ] = { "0",
"1", "2", "3", "4", "5",
"6", "7", "8",

"9", "A", "B",
"C", "D", "E", "F" };

if (n>15)

DecToHex ( n/16 );

printf( "%s", numarr[n%16] );

}

7)

**Power**
double Pow( double a, int n ) {

if ( n==0 )

return( 1 );

else if ( n>0 )

return( a * Pow ( a, n-1 ) );

else

return( (1/a) * Pow ( a, n+1 ) );

}

**8) program to find processor type**

int checkCPU( void )

{

char far *s = "\270\001pP\235\234X\313";

return!!(((int(far*)())s) ()AND(( 0x88 + ((
286 | 386 )*4))<<4 span="">

}

int main( void )

{

printf( "CPU Type is %s\n", checkCPU
() ? "386" : "286" );

return(0);

}

the contents are quiet interesting. I will be waiting for your next post.

ReplyDeletethank you for sharing your great experience among us.

ReplyDeleteGreat article …Thanks for your great information, the contents are quiet interesting. I will be waiting for your next post.

ReplyDeletekeep posting such good and meaningful articles.

ReplyDeleteThanks for sharing. I hope it will be helpful to many people that are searching for this topic. Keep posting guys and keep this forum a great place to learn things.

ReplyDeleteI really like to read your blogs as they contains very important and informative content. I appreciate your efforts. Cheers.

ReplyDeleteHi, Neat post. Therе is an issue together with yοur sіte

ReplyDeletein internet explorer, cοuld teѕt thіs? IE still is

the market chief and a laгgе section of

рeоple will pаss ονer yоuг wοnderful writing beсausе οf this pгoblem.

My ωebрage ... http://www.householdtipsntricks.com

I will probably be back again to browse much more, many thanks for the data.

ReplyDeleteI will probably be back again to browse much more, many thanks for the data.

ReplyDeleteThis is wonderful. I am not quite familiar with the internet, but I believe that what I just read is some good material. Thanks for continuing to write such wonderful articles. God bless.

ReplyDeleteI really appreciate your professional approach. please keep it up good work !!

ReplyDeleteyou're saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand.

ReplyDelete