Wednesday, February 23, 2011

ISC 2005 Computer Practical Solved Paper

Question 1.


Write a program which takes a string (maximum 80 characters terminated by a full stop. The words in this string are assumed to be separated by one or more blanks.
Arrange the words of the input string in descending order of their lengths. Same length words should be sorted alphabetically. Each word must start with an uppercase letter and the sentence should be terminated by a full stop.

Test your program for the following data and some random data.

SAMPLE DATA:
      INPUT:
      "This is human resource department."
    
     OUTPUT:
      Department Resource Human This Is. 

     INPUT:
      "To handle yourself use your head and to handle others use your heart."

     OUTPUT:
      Yourself Handle Handle Others Heart Head Your Your And Use Use To To.

For Solution: CLICK HERE

Codes of the program



ISC 2019 English Paper II Suggestions (New Syllabus): CLICK HERE


Question 2.

A wondrous square is an n by n grid which fulfils the following conditions:
    (i) It contains integers from 1 to n2, where each integer appears only once.
    (ii) The sum of integers in any row or column must add up to 0.5 * n * (n2 + 1).

For example the following grid is a wondrous square where the sum of each row or column is 65 when n = 5 :

 17
24
 2
 8
 15
 23
 5
 7
 14
 16
 4
 6
13 
 20
 22
 10
 12
 19
 21
 3
 11
 18
 25
 2
 9

Write a program to read n (2 < = n < = 10) and the values stored in these n by n cells and output if the grid represents a wondrous square or not.
Also output all the prime numbers in the grid along with their row index and column index as shown in the output. A natural number is said to be prime if it has exactly two divisors. E.g. 2, 3, 5, 7, 11,.......
The first element of the given grid i.e. 17 is stored at row index 0 and column index 0 and the next element in the row i.e. 24 is stored at row index 0 and column index 1.

Test your program for the following data and some random data.

SAMPLE DATA:
      INPUT :        N = 4
                            

 16
 15
 1
 2
 6
 4
 10
 14
 9
 8
 12
 5
 3
 7
 11
 13

OUTPUT:
YES IT REPRESENTS A WONDROUS SQUARE.

 PRIME  
  ROW INDEX 
  COLUMN INDEX
 2
 0
 3
 3
 3
 0
 5
 2
 3
 7
 3
 1
11
3
2
13
3
3


import java.io.*;
  class Program1
 {
 int arr[][],arr1[];;
  int n,i,j,x=0,r,c;
  int flag;
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  public void take()throws Exception
  {
   System.out.println("\nEnter the size of array(row and column same):");
   n=Integer.parseInt(br.readLine().trim());
   arr=new int[n][n];
   arr1=new int[2*n];
   for(i=0;i< n;i++)
   {
   for(j=0;j< n;j++)
   {
     System.out.println("\nEnter the value:");
     arr[i][j]=Integer.parseInt(br.readLine());
     }
     }
   System.out.println("\nThe matrix is\n"); 
     for(i=0;i< n;i++)
     {
     r=0;
     c=0;
      for(j=0;j< n;j++)
      {
      System.out.print(arr[i][j]+" ");
       r=r+arr[i][j];
       c=c+arr[j][i];
       }
        System.out.println();
       arr1[x]=r;
       arr1[x+n-1]=c;
       x++;
       }
       for(i=0;i< x;i++)
       {
        if(arr1[i]!= 0.5 * n * (n*n + 1))
        break;
        }
        if(i==x)
        System.out.println("YES IT REPRESENTS A WONDROUS SQUARE.");
        else
        System.out.println("IT IS NOT A WONDROUS SQUARE.");
        System.out.println("PRIME  ROW  COLUMN");
        for(i=0;i< n;i++)
        {
         for(j=0;j< n;j++)
         {
         if(prime(arr[i][j]))
         System.out.println(arr[i][j]+ "   "+i+ "   "+j);
        }
        }
        }
        private boolean prime(int no)
        {
         int index;
         for(index=2;index< no;index++)
         {
          if(no%index==0)
          break;
         }
         if(index==no)
         return true;
         else
         return false;
        }
     public static void main(String args[])throws Exception
     {
      Program1 ob=new Program1();
      ob.take();
      }
      }


Question 3.


We would like to generate all possible anagrams of a word. For example if the given word is 'TOP', there will be 6 possible anagrams:
       TOP
       TPO
       OPT 
       OTP
       PTO
       POT

An anagram must be printed only once. You may output the anagrams in any order. Also output the total number of anagrams. You assume that the number of letter, n, in the word will be 7 at most, i.e. n<= 7
Test your program for the given data and some random data.

SAMPLE DATA:
     INPUT:
                       TO

OUTPUT:
                     TO
                     OT
Total number of anagrams = 2

INPUT :
                     LEAN
OUTPUT:
                     LEAN
                     LENA
                     LAEN
                     LANE
                     LNEA
                     LNAE
                     EALN
                     EANL
                     ELAN
                     ELNA
                     ENLA
                     ENAL
                     ALNE
                     ALEN
                     ANLE
                     ANEL
                     AENL
                     NLEA
                     NLAE
                     NELA
                     NEAL
                     NALE
                     NAEL
Total number of anagrams = 24


Codes of the program

import java.io.*;
 public class Anagrams
 {
String str;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int counter=0;
public void take()throws Exception
 {
   System.out.println("\nEnter the word:");
   str=br.readLine();
   show("", str);
   System.out.println(“Total number of anagrams =”+counter);
 }
   public void show(String s, String str)
  {
      if(str.length()< = 1)
     {
       counter++;
       System.out.println(s+str);
     }
    else
     {
        for(int i = 0; i< str.length(); i++)
       {
          String str1 = str.substring(i, i + 1);
          String str2 = str.substring(0, i);
          String str3 = str.substring(i + 1);
          show(s + str1, str2 + str3);
        }
     }
   }
public static void main(String args[])throws Exception
{
 Anagrams ob=new Anagrams();
ob.take();
}
}

 Related Posts: ISC Computer Practical Programs - 2006
ISC 2007 Computer Practical Paper
ISC Computer Practical Paper - 2008
ISC 2010 Computer Practical

17 comments:

  1. any last minute suggestions...??

    ReplyDelete
  2. Be relaxed and go through the logic of the practical paper programs of previous years. This will help you to solve any program.

    ReplyDelete
  3. thnks a lot for encouragement sir..

    ReplyDelete
  4. Sir....could u post the 2009 paper 2..thanx 4r ur help...

    ReplyDelete
  5. I think the programs of 2009 are posted as individual programs. Search those programs in my site.

    ReplyDelete
  6. sir please post the technical analysis of anagram of word program please sir............

    ReplyDelete
  7. sir coulnt find it will you lease give the link

    ReplyDelete
  8. Please specify the program, I 'll solve it.

    ReplyDelete
  9. is show(s+str) is used in place of system.out.println?

    ReplyDelete
  10. sir plz help me with function parsing..........

    ReplyDelete
  11. sir could you help me in doing a wonderous square

    ReplyDelete
  12. Good easy logic for the anagram program..thanks...

    ReplyDelete
  13. import java.io.*; class anagram {
    public static void main(String args[])
    {
    InputStreamReader read=new InputStreamReader(System.in);
    BufferedReader br=new BufferedReader(read);
    System.out.println("ENTER THE NUMBER OF LETTERS IN THE WORD");
    int n=Integer.parseInt(br.readLine());
    System.out.println("ENTER THE WORD") ;
    String s=br.readLine();
    if(n==1)
    System.out.println(s) ;
    if(n==2)
    System.out.println(s+"\n"+s.charAt(1)+s.charAt(0));
    if(n==3)
    {
    for(int i=0;i<3;i++)
    {
    for(int j=0;j<3;j++)
    {
    for(int k=0;k<3;k++)
    {
    if(i!=j&&j!=k&&k!=i)
    System.out.println(s.charAt(i)+""+s.charAt(j)+""+s.charAt(k));
    }
    }
    }
    }
    if(n==4)
    {
    for(int i=0;i<4;i++)
    {
    for(int j=0;j<4;j++)
    {
    for(int k=0;k<4;k++)
    {
    for(int p=0;p<4;p++)
    {
    if(i!=j&&j!=k&&k!=p&&p!=i&&p!=j&&k!=i)
    System.out.println(s.charAt(i)+""+s.charAt(j)+""+s.charAt(k)+""+s.charAt(p));
    }
    }
    }
    }
    }
    }
    }

    ReplyDelete

Subscribe via email

Enter your email address:

Delivered by FeedBurner