Alphabetical Arrangement

/*Alphabetical arrangement */
#include
#include
#include
void main()
{
char string[50];
char temp;
int i,j,l;
printf("\nEnter any string: ");
scanf("%s",string);l=strlen(string);
for(i=0;i{
for(j=0;j{
if(string[j]>string[j+1])
{
temp=string[j];
string[j]=string[j+1];
string[j+1]=temp;
}
}
}printf("\n\nAlphabetical arrangement makes: ");
puts(string);
getch();
}

PROGRAM TO GENERATE PASCAL'S TRIANGLE

/* PROGRAM TO GENERATE PASCAL'S TRIANGLE*/
#include
#include
void main()
{
int binom,q,r,x,num;binom=1;
q=0;clrscr();
printf("\n\t\t\tPASCAL'S TRIANGLE ");
printf("\nInput the number of rows :");
scanf("%d",&num);
printf("\nPascal's triangle:\n ");
while(q for(r = 10 ; r>q ; r--)
{
printf(" ");
}
for(x=0;x<=q;x++)
{
if((x==0)(q==0))
{
binom=1;
}
else {
binom=(binom*(q-x+1))/x;
}
printf(" %d ",binom);
}
printf("\n\n");++q;}getch();}

Overloading using templates

#include
#include
void fun(float a)
{
cout<<"float"<}
template
void fun(T a)
{
cout<<"hello"<}
void main()
{
clrscr();
int a=10;
fun(a);
float x=25.09f;
fun(x);
getch();
}

Fibonacci Series Using Recursive Function

//fibonacci series using recursive function
#include
#include
long fibo(int n)
{
if ((n==0)(n==1))
return 0 ;
else if
(n==2)
return 1;
else
return (fibo(n-1)+fibo(n-2));
}
void main()
{
int num,i=0;
printf("Enter the no of terms:");
scanf("%d",&num);
while (i++i;
printf("The %dth term of fabonacci series is: %d \n",i,fibo(i));
}
getch();
}

//
Enter the number of terms:4
The 1st term of fibonacci series is:0
The 1st term of fibonacci series is:1
The 1st term of fibonacci series is:1
The 1st term of fibonacci series is:2