Search This Blog

Loading...

Saturday, February 25, 2012

2012 ISC Computer Science Practical Solved Paper


Program number 1 of 2012 ISC computer science practical paper

A prime palindrome integer is a positive integer (without leading zeros) which is prime as well as a palindrome. Given two positive integers m and n, where m < n, write a program to determine how many prime-palindrome integers are there in the range between m and n (both inclusive) and output them.

The input contains two positive integers m and n where m< 3000 and n< 3000. Display the number of prime palindrome integers in the specified range along with their values in the format specified below:


Test your program with the sample data and some random data:

Example 1:
INPUT: m=100
N=1000
OUTPUT: The prime palindrome integers are:
101,131,151,181,191,313,351,373,383,727,757,787,797,919,929

Frequency of prime palindrome integers: 15


Example 2:
INPUT:
M=100
N=5000
OUTPUT: Out of Range


import java.io.*;
class PalPrime
{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int m,n;
    int c;
    public void showPalPrime() throws Exception
    {
         c=0;
         System.out.println("Enter the Lower Limit:");
         m=Integer.parseInt(br.readLine());
        System.out.println("Enter the Upper Limit:");
         n=Integer.parseInt(br.readLine());
         if(m> =n || n> =3000)
         System.out.println("Out of Range.");
         else
         {
            System.out.println("The Prime Palindrome integers are:");
            while(m <=n)
             {
               if(palPrime(m))
               {
                    if(c==0)
                    System.out.print(m);
                    else
                    System.out.print(", "+m);
                    c++;
                }
                m++;
            }
                System.out.println("\nFrequency of Prime Palindrome integers: "+c);
            }
        }
        private boolean palPrime(int x)
        {
            boolean bool=false;
            int i;
            int rev=0;
            for(i=2;i<  x;i++)
            {
                 if(x%i==0)
                 break;
                }
                if(i==x)
                bool=true;
                if(bool)
                {
                    for(i=x;i >0;i=i/10)
                    {
                         rev=rev*10+i%10;
                        }
                        if(rev!=x)
                        bool=false;
                    }
                    return bool;
                }
                public static void main(String args[]) throws Exception
                {
                     PalPrime ob=new PalPrime ();
                     ob.showPalPrime();
                    }
                }
                       
  
Program number 2 of 2012 ISC computer science practical paper

Write a program to accept a sentence as input. The words in the string are to be separated by a blank. Each word must be in upper case. The sentence is terminated by either “.”,”!” or “?”. Perform the following tasks:

Obtain the length of the sentence (measured in words)
Arrange the sentence in alphabetical order of the words

Test your program with the sample data and some random data:

Example 1:
INPUT: NECESSITY IS THE MOTHER OF INVENTION.

OUTPUT:
Length: 6
Rearranged Sentence:
INVENTION IS MOTHER NECESSITY OF THE

Example 2:

INPUT: BE GOOD TO OTHERS.
OUTPUT:
Length: 4
Rearranged Sentence: BE GOOD OTHERS TO


import java.io.*;
import java.util.*;
class Matrixmult
{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String str;
   String words[];
   StringTokenizer stk;
    int i,j,c,x;
   public void take()throws Exception
   {
       int flag;
       while(true)
       {
           flag=0;
       System.out.println("Enter the sentence:");
       str=br.readLine();
      for(i=0;i <  str.length();i++)
      {
          if(Character.isLowerCase(str.charAt(i)))
          {
              flag=1;
              break;
            }
        }
        if (flag==0)
        break;
    }
       stk=new StringTokenizer(str," .,?!");
       c=stk.countTokens();
       x=0;
       words=new String[c];
       while(stk.hasMoreElements())
       {
           words[x++]=stk.nextToken();
        }
        System.out.println("Length="+c);
        for(i=0;i <  x-1;i++)
        {
             for(j=i+1;j < x;j++)
             {
                 if(words[i].compareTo(words[j])>0)
                 {
                     str=words[i];
                     words[i]=words[j];
                     words[j]=str;
                    }
                }
            }
            System.out.println("\nRearranged Sentence:\n");
            for(i=0;i <  c;i++)
            System.out.print(words[i]+" ");
        }
                public static void main(String args[]) throws Exception
                {
                     Matrixmult ob=new Matrixmult();
                     ob.take();
                    }
                }
                        

Same program using alternate technique.
  
import java.io.*;
import java.util.*;
class Matrixmult
{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String str;
   String words[]=new String[20];
   StringTokenizer stk;
    int i,j,x;
   public void take()throws Exception
   {
       int flag;
       while(true)
       {
           flag=0;
       System.out.println("\nEnter the sentence:");
       str=br.readLine();
      for(i=0;i < str.length();i++)
      {
          if(Character.isLowerCase(str.charAt(i)))
          {
              flag=1;
              break;
            }
        }
        if (flag==0)
        break;
    }
    str=str.replace('.',' ');
   str=str.replace(',',' ');
   str=str.replace('?',' ');
   str=str.replace('!',' ');
       x=0;
     
       while(true)
       {
          i=str.indexOf(' ');
          if(i < 0)
          break;
          words[x++]=str.substring(0,i);
          str=str.substring(i+1);
          }
          words[x++]=str;
         
        System.out.println("Length="+(x-1));
        for(i=0;i <  x-1;i++)
        {
             for(j=i+1;j <  x;j++)
             {
                 if(words[i].compareTo(words[j]) > 0)
                 {
                     str=words[i];
                     words[i]=words[j];
                     words[j]=str;
                    }
                }
            }
            System.out.println("\nRearranged Sentence:\n");
            for(i=0;i <  x;i++)
            {
                if(i==x-1)
                System.out.print(words[i]);
                else
                System.out.print(words[i]+" ");
            }
        }
                public static void main(String args[]) throws Exception
                {
                     Matrixmult ob=new Matrixmult();
                     ob.take();
                    }
                }
                       

 Program number 3 of 2012 ISC computer science practical paper

Write a program to declare a matrix A [][] of order (MXN) where ‘M’ is the number of rows and ‘N’ is the number of columns such that both M and N must be greater than 2 and less than 20. Allow the user to input integers into this matrix. Perform the following tasks on the matrix:

Display the input matrix

Find the maximum and minimum value in the matrix and display them along with their position.

Sort the elements of the matrix in ascending order using any standard sorting technique and rearrange them in the matrix.

Output the rearranged matrix.


Sample input Output

INPUT:
M=3
N=4

Entered values: 8,7,9,3,-2,0,4,5,1,3,6,-4


Original matrix:


8  7  9  3
-2  0  4  5
1  3  6  -4


Largest Number: 9
Row: 0
Column: 2
Smallest Number: -4
Row=2
Column=3

Rearranged matrix:

-4  -2  0  1
3  3  4  5
6  7  8  9


import java.io.*;
class Matrixmult
{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   int arr[][];
   int r,c,max,min,maxi,maxj,mini,minj,i,j,m,n;
    public void take()throws Exception
   {
       boolean bool=true;
       while(bool)
       {
       System.out.println("\nEnter the number of rows:");
       r=Integer.parseInt(br.readLine());
        System.out.println("\nEnter the number of columns:");
       c=Integer.parseInt(br.readLine());
       if(r < 2 || c < 2 || r > 20 || c > 20)
        bool=true;
        else
        bool=false;
    }
    arr=new int[r][c];
    for(i=0;i <  r;i++)
    {
        for(j=0;j < c;j++)
        {
             System.out.println("\nEnter Value:");
             arr[i][j]=Integer.parseInt(br.readLine());
            }
        }
        max=arr[0][0];
        min=arr[0][0];
        maxi=0;
        mini=0;
        maxj=0;
        minj=0;
        for(i=0;i < r;i++)
        {
             for(j=0;j< c;j++)
             {
                 if(arr[i][j]> max)
                 {
                     max=arr[i][j];
                     maxi=i;
                     maxj=j;
                    }
                    else if(arr[i][j]<  min)
                    {
                         mini=i;
                         minj=j;
                         min=arr[i][j];
                        }
                    }
                }
                 System.out.println("\nOriginal Array\n");
                 for(i=0;i< r;i++)
                 {
                      for(j=0;j< c;j++)
                      {
                           System.out.print(arr[i][j]+" ");
                        }
                        System.out.println();
                    }
               
                System.out.println("\nMaximum Value="+max);
               System.out.println("\nRow="+maxi);
              System.out.println("\nColumn="+maxj);
              System.out.println("\nMinimum Value="+min);
               System.out.println("\nRow="+mini);
              System.out.println("\nColumn="+minj);
             
              for(m=0;m< r;m++)
              {
                  for(n=0;n< c;n++)
                  {
                  for(i=0;i< r;i++)
                  {
                       for(j=0;j< c;j++)
                       {
                            if(arr[m][n]< arr[i][j])
                            {
                                 min=arr[m][n];
                                 arr[m][n]=arr[i][j];
                                 arr[i][j]=min;
                                }
                            }
                        }
                    }
                }
                     System.out.println("\nSorted Array\n");
                 for(i=0;i< r;i++)
                 {
                      for(j=0;j< c;j++)
                      {
                           System.out.print(arr[i][j]+" ");
                        }
                        System.out.println();
                    }
     
        }
                public static void main(String args[]) throws Exception
                {
                     Matrixmult ob=new Matrixmult();
                     ob.take();
                    }
                }
                       
Algorithm and variable description of the above programs will be posted in this page very soon. 


Related Post:

Last Minute Suggestions for ISC 2013

27 comments:

  1. nice... i did the 3rd question

    ReplyDelete
  2. if only I had seen class X programmes then I would have scored full marks. I did 75% of the first question.

    ReplyDelete
  3. u srsly r amazing sir.........m in 12th right nw.........nd just shifted to isc frm cbse last year...........its been vry hard fr me to cover the java of wat my fellow mates did frm the 8th std..........and after going through ur programs it has made a lot more easy fr me....i srsly thank u alot!!!!!

    ReplyDelete
    Replies
    1. Thanks but please don't write in SMS language.

      Delete
    2. Mr Dhananjoy Chakraborty I think it was kind of mean from your side to reply to his/her appreciation like that ...I think it was really nice of his/her to respect and appreciate your work...and I think it really shouldn't matter whether he/her wrote in SMS language or no...because it means the same....with all due respect sir I think on personal terms that it was kind of rude....sorry if any of my words were wrong....and thank you for your help through the program's you post

      Delete
    3. In search engine, sms languages are not accepted and that is the only reason for asking not to use sms language.

      Delete
  4. Sir, could you please post the expected programs for isc 2013?

    ReplyDelete
  5. Expected for 2013 please sir...

    ReplyDelete
    Replies
    1. sir, pls could you teach me the logic that is needed to create any program

      Delete
    2. You go through the page 'Few words about algorithm on data structure in C Programming' in this blog. Although it is a page on C - Data Structure, it will help you to build your logic.

      Through program we get our job done by programs. To get the job done, we have to pass the instructions in perfect sequence and there should not be any doubtful instruction. This is the logic of programming. If any doubt, please contact again.

      Delete
  6. Expected questions for 2013 plzz sir

    ReplyDelete
  7. sir please post the solution of this question-

    WAP to input a positive natural number N and output all combinations of consecutive natural number,which add up to give N

    example: N=15
    output:
    1 2 3 4 5
    4 5 6
    7 8

    ReplyDelete
  8. is this program for Q.1 of 2012 correct??
    import java.util.*;
    class Primepalindrome
    {
    private int n;
    private int m;
    private Scanner sc;
    //default const.
    public Primepalindrome()
    {
    n=0;
    m=0;
    sc=new Scanner(System.in);
    }
    //fn to check whether a no. is prime
    public boolean isPrime(int num)
    {
    int c=0;
    for(int i=1;i<=num;i++)
    {
    if(num%i==0)
    {
    c++;
    }
    }
    return(c==2);
    }
    //fn to check whether a no. is palindrome
    public boolean isPalindrome(int num)
    {
    int n1=num;

    int rev=0;
    int d=0;
    while(n1!=0)
    {
    d=n1%10;
    rev=(rev*10)+d;
    n1=n1/10;
    }
    return(rev==num);
    }
    //main fn
    public void main()
    {
    System.out.println("entr a no. m which is less than 3000 ");
    m=sc.nextInt();
    System.out.println("entr a no. n which is less than 3000");
    n=sc.nextInt();
    int f=0;
    if(m<n&& n<=3000)
    {
    for(int i=m;i<=n;i++)
    {
    if(isPalindrome(i)==true && isPrime(i)==true)
    {
    System.out.println(i);
    f++;
    }
    }
    System.out.println("Frequency of prime palindrome integers: " +f);
    }

    else
    {
    System.out.println("yo no. is not in d given range");
    }

    }
    }



    ReplyDelete
  9. import java.util.*;
    class Primepalindrome
    {
    private int n;
    private int m;
    private Scanner sc;
    //default const.
    public Primepalindrome()
    {
    n=0;
    m=0;
    sc=new Scanner(System.in);
    }
    //fn to check whether a no. is prime
    public boolean isPrime(int num)
    {
    int c=0;
    for(int i=1;i<=num;i++)
    {
    if(num%i==0)
    {
    c++;
    }
    }
    return(c==2);
    }
    //fn to check whether a no. is palindrome
    public boolean isPalindrome(int num)
    {
    int n1=num;

    int rev=0;
    int d=0;
    while(n1!=0)
    {
    d=n1%10;
    rev=(rev*10)+d;
    n1=n1/10;
    }
    return(rev==num);
    }
    //main fn
    public void main()
    {
    System.out.println("entr a no. m which is less than 3000 ");
    m=sc.nextInt();
    System.out.println("entr a no. n which is less than 3000");
    n=sc.nextInt();
    int f=0;
    if(m<n&& n<=3000)
    {
    for(int i=m;i<=n;i++)
    {
    if(isPalindrome(i)==true && isPrime(i)==true)
    {
    System.out.println(i);
    f++;
    }
    }
    System.out.println("Frequency of prime palindrome integers: " +f);
    }

    else
    {
    System.out.println("yo no. is not in d given range");
    }

    }
    }


    ReplyDelete
  10. im not familiar to blue j what i "&lt" in all for loops

    ReplyDelete
  11. how to write algorithms for these programs ??

    ReplyDelete
    Replies
    1. By tomorrow evening I will update the page with algorithms of the three programs.

      Delete
  12. sir give me some excepted question isc board for computer pratical plz plz help me sir........

    ReplyDelete
    Replies
    1. Expected programs are already posted as 'last minutes suggesion for ISC 2013'.

      Delete
  13. sir could you please post the programs expected for 2014

    ReplyDelete
  14. sir, could you please post the guess practical question paper of isc.

    ReplyDelete

CHECK HERE FOR PREVIOUS POSTS

Google+ Followers

Subscribe via email

Enter your email address:

Delivered by FeedBurner