9Google AdSense

A program to sort n strings and then disply the sorted list of strings.

#include <stdio.h>
#include <conio.h>
#include <string.h>

void namesort(char name[15][20],int n);
void main()
{
     int i,n;
     char name[15][20],c;
     clrscr();
    printf("How many names u want to enter : ");
    scanf("%d",&n);
    scanf("%c",&c);
    printf("\nEnter  name : \n\n");
    for(i=0;i<n;i++)
    gets(name[i]);

    namesort(name,n);

    printf("\n\n******After Sorting******\n\n");
    for(i=0;i<n;i++)
       printf("%s\n",name[i]);
    getch();
}

void namesort(char name[15][20],int n)
{
      int i,j;
      char *temp;
      for(i=0;i<n;i++)
      {
     for(j=0;j<n-1;j++)
    {
        if(strcmp(name[j],name[j+1])>0)
        {
        strcpy(temp,name[j]);
        strcpy(name[j],name[j+1]);
        strcpy(name[j+1],temp);
        }
     }
      }
}

write a program to display the fibonacee series of n numbers.

import java.io.*;

public class Fibo
{
    public static void main(String a[])
   {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String str;
        int i;
        int ary[];
        ary=new int[100];
        try{      
               System.out.println("Enter the number N : ");
               str=br.readLine();
               i=Integer.parseInt(str);
               ary[1]=1;
               ary[2]=2;
               for(int lp=3;lp<=i;lp++)
                   ary[lp]=ary[lp-1]+ary[lp-2];
              
               System.out.println("Fibonacee series : ");
               for(int ji=1;ji<=i;ji++)
                    System.out.print(" "+ary[ji]);
           }
        catch(Exception e)  {  }
   }
}