Home > ISC_Computer Science, Previous Yrs Practical Papers > ISC Practical Paper – 2012 (Solved)

ISC Practical Paper – 2012 (Solved)

January 22, 2013 Leave a comment Go to comments

COMPUTER SCIENCE

Paper – 2

(PRACTICAL)

(Reading Time: 15 minutes)

 (Planning Session AND Examination Session: Three Hours)

————————————————————————————————————

The total time to be spent on the Planning and the Examination Session is Three hours.

After completing the Planning Session, the candidate may begin with the Examination Session.

A maximum of 90 minutes is permitted to begin the Examination Session.

(Maximum Marks: 80)

————————————————————————————————————

As it is a practical examination the candidate is expected to do the following:

  1. Write an algorithm for the selected problem.    [10]
  2. Algorithm should be expressed clearly using ay standard scheme such as pseudo code or in steps which are simple enough to be obviously computable.
  3. Write a program in JAVA language. The program should follow the algorithm and should             [20]
    be logically and syntactically correct.
  4. Document the program using mnemonic names / comments, identifying and clearly                        [10]
    describing the choice of data types and meaning of variables.
  5. Code / Type the program on the computer and get a printout (hard copy). Typically this                 [10]
    should be a program that compiles and runs correctly.
  6. Test run the program on the computer using the given sample data and get a printout of                 [20]
    the output in the format specified in the problem.
  7. Viva-Voce on the Selected Problem.     [20]

 Solve any one of the following Problems:

 Question 1.

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>=100 and n<= 3000. Display 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 PrimePal
{
    public void showPrimePal() throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int m,n, 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(checkPrimePal(m))
                {
                    if(c==0)
                        System.out.print(m);
                    else
                        System.out.print(“, “+m);
                    c++;
                }
                m++;
            }
            System.out.println(“\nFrequency of Prime Palindrome integers: “+c);
        }
    }
    boolean checkPrimePal(int x)
    {
        boolean flag=false;
        int c=0, temp=x;
        int rev=0,rem=0;
        for(int i=1;i<=x;i++)
        {
            if(x%i==0)
                c++;
        }
        if(c<=2)
        {
            while(x!=0)
            {
                rem=x%10;
                rev=rev*10+rem;
                x/=10;
            }
            if(rev==temp)
                flag=true;
        }
        return flag;
    }
    public static void main(String args[]) throws IOException
    {
        PrimePal ob=new PrimePal ();
        ob.showPrimePal();
    }
}

Question 2.

 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:

(i)  Obtain the length of the sentence. (measured in words)

(ii) 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.*;
class WordsInSentence
{
    public void take() throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String str, words[], stk=””;
        int i,j,c=0,flag, len;
        char ch;
        while(true)
        {
            flag=0;
            System.out.println(“Enter the sentence:”);
            str=br.readLine();
            len= str.length();
            words=new String[len];
            for(i=0;i
            {
                if(Character.isLowerCase(str.charAt(i)))
                {
                    flag=1;
                    break;
                }
            }
            if (flag==0)
                break;
            else
                System.out.println(“Enter the sentence again with all uppercase letters”);
        }
        i=0;
        while(i<len)
        {
            ch=str.charAt(i);
            if(ch==’ ‘|| ch==’.’ || ch==’?’ || ch==’!’)
            {
                words[c]=stk;
                c++;
                i++;
                stk=””;
            }
            else
            {
                stk+=ch;
                i++;
            }
        }
        for(i=0;i<c;i++)
        {
            for(j=0;j<c-1;j++)
            {
                if((words[j].compareTo(words[j+1]))>0)
                {
                    stk=words[j];
                    words[j]=words[j+1];
                    words[j+1]=stk;
                }
            }
        }
        System.out.println(“Length= “+c);
        System.out.println(“\nRearranged Sentence:\n”);
        for(i=0;i<c;i++)
            System.out.print(words[i]+” “);
    }
    public static void main(String args[]) throws IOException
    {
        WordsInSentence ob=new WordsInSentence();
        ob.take();
    }
}

Question 3.

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:

  1. Display the input matrix
  2. Find the maximum and minimum value in the matrix and display them along with their position.
  3. Sort the elements of the matrix in ascending order using any standard sorting technique and rearrange them in the matrix.
  4. Output the rearranged matrix.

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

Example 1.

INPUT:

M=3

N=4

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

 OUTPUT:

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 Matrix
{
public void take()throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int arr[][],m,n;
int g,h,i,j,max,min,maxr,maxc,minr,minc;

while(true)
{
System.out.println(“\nEnter the number of rows :”);
m=Integer.parseInt(br.readLine());
System.out.println(“\nEnter the number of columns:”);
n=Integer.parseInt(br.readLine());
if(m<2 || n<2 || m>20 || n>20)
System.out.println(“\nEnter the number of rows and columns”);
else
break;
}
arr=new int[m][n];
for(i=0;i<m; i++)
{
for(j=0;j<n;j++)
{
System.out.println(“\nEnter Value:”);
arr[i][j]=Integer.parseInt(br.readLine());
}
}
max=arr[0][0];
min=arr[0][0];
maxr=0;
minr=0;
maxc=0;
minc=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(arr[i][j]>max)
{
max=arr[i][j];
maxr=i;
maxc=j;
}
else if(arr[i][j]< min)
{
minr=i;
minc=j;
min=arr[i][j];
}
}
}
System.out.println(“\nOriginal Matrix\n”);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
System.out.print(arr[i][j]+” “);
}
System.out.println();
}

System.out.println(“\nMaximum Value=”+max);
System.out.println(“\nRow=”+maxr);
System.out.println(“\nColumn=”+maxc);
System.out.println(“\nMinimum Value=”+min);
System.out.println(“\nRow=”+minr);
System.out.println(“\nColumn=”+minc);

for(g=0;g<m;g++)
{
for(h=0;h<n;h++)
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(arr[g][h]< arr[i][j])
{
min=arr[g][h];
arr[g][h]=arr[i][j];
arr[i][j]=min;
}
}
}
}
}
System.out.println(“\nSorted Array\n”);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
System.out.print(arr[i][j]+” “);
}
System.out.println();
}

}
public static void main(String args[]) throws Exception
{
Matrix ob=new Matrix();
ob.take();
}
}

You may like to see these papers .

About these ads
  1. Anonymous
    June 7, 2014 at 9:08 am

    mam can i get last 10 years solved practical question

    • June 15, 2014 at 8:22 am

      @someone: it will take time to post

  2. Rishabh Arora
    May 13, 2013 at 10:09 am

    Can i get the algorithms of these programs.?

  3. Mahima
    February 17, 2013 at 5:05 pm

    Hello Mam, I am having a great difficulty in understanding the logic of program to print the pascal’s triangle and i am very much confused about writing algorithms. I mean i dont understand what the examiner wants precisely in the algorithm.

    • February 17, 2013 at 5:46 pm

      @mahima:I will post the code for pascal’s triangle tomorrow under “various pattern programs”. keep a check. And for algorithms, you have to write the finite stepwise solution of the given problem in English language. I have given an example in one of the comments, you can see.

    • February 19, 2013 at 10:53 am

      @mahima: program for pascal’s triangle is already there in the post “various pattern programs”

  4. raj
    February 9, 2013 at 6:38 am

    Hello mam!!..can u send any program on string manipulation,number manipulation and date via e-mail..it would be very helpful for my upcoming practical

    • February 9, 2013 at 4:59 pm

      @raj: if you solve previous years practical papers, you will have enough practice of string and number manipulation and date related problems.

  5. Anonymous
    February 8, 2013 at 4:14 pm

    please Solve this question
    1/3 =.(3)
    22/5=4.4
    1/7=.(142857)
    45/56=.803(571428)
    Mam i am not able to do this mam please help

  6. KRITI SINGHAL
    January 27, 2013 at 6:46 am

    Hey mam…..can u plz tell me how to write algorithms in ISC comp. practical….is there any pattern 4r writing algos in ISC????

    i dnt knw how to write algorithms…..

    • January 28, 2013 at 9:45 pm

      @Kriti: Algorithm is a stepwise solution to the problem written in simple english language. The number of steps should be finite and easily understandable.eg. algorithm to check x is divisible by y or not:
      BEGIN
      INPUT x,y
      IF x is divisible by y THEN
      OUTPUT “Yes x is divisible by y”
      ELSE
      OUTPUT “No x is not divisible by y”
      ENDIF
      END

      • KRITI SINGHAL
        February 8, 2013 at 9:19 pm

        thnxxx mam 4r ur help..mam can u plzz tell me some imp. questions 4r dis year????

        • February 9, 2013 at 5:09 pm

          @kriti: practice on string manipulation, number manipulation and date related problems.Previous years papers will give you enough practice of such questions

  7. Shreya
    January 23, 2013 at 4:07 pm

    hello ma’am thanks for this…do you have any idea what type of questions can come this year in practical ?

    • January 24, 2013 at 12:46 pm

      @shreya: you must practice questions based on string manipulation, number manipulation, date and time and arrays(single/double dimensional) for practicals.

      • yash sharma
        February 9, 2013 at 8:44 pm

        plzz will u help me …vn u plzz gve me a sample paper of practical for dis year…plzzz i need it…

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 199 other followers

%d bloggers like this: