Share this:
ISC COMPUTER PRACTICAL PAPER 2012 SOLVED

ISC Practical Paper – 2012 (Solved)

ISC Practical Paper – 2012 (Solved)

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

ecolebooks.com

OUTPUT: Out of Range

Solution:

import java.io.*;

class PrimeP
{
    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
    {
        PrimeP ob=new PrimeP ();
        ob.showPrimePal();
    }
}
——————end————————–

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

Solution:

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        {
            ch=str.charAt(i);
            if(ch==’ ‘|| ch==’.’ || ch==’?’ || ch==’!’)
            {
                words[c]=stk;
                c++;
                i++;
                stk=””;
            }
            else
            {
                stk+=ch;
                i++;
            }
        }
        for(i=0;i        {
            for(j=0;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            System.out.print(words[i]+” “);
    }
    public static void main(String args[]) throws IOException
    {
        WordsInSentence ob=new WordsInSentence();
        ob.take();
    }
}
——————end————————

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:

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.
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

Solution: 

import java.util.*;
class Matrix
{
public static void main(String args[])
{
int p=0,smallest=4999,larger=0,maxr=0,maxc=0,minr=0,minc=0;
Scanner sc=new Scanner(System.in);
System.out.println(“enter m*n”);
int m=sc.nextInt();
int n=sc.nextInt();
int a[][]=new int[m][n];
int b[]=new int[1000];
for(int i=0;i{
for(int j=0;j{
a[i][j]=sc.nextInt();
}
}

for(int i=0;i{
for(int j=0;j{
if(a[i][j]{
smallest=a[i][j];
maxr=i;
maxc=j;
}
if(a[i][j]>larger)
{
larger=a[i][j];
minr=i;
minc=j;
}
}
}
for(int i=0;i{
for(int j=0;j{
b[p]=a[i][j];
p++;
}
}

for(int i=0;i{
for(int j=0;j{
if(b[j]>b[j+1])
{
int temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
p=0;
for(int i=0;i{
for(int j=0;j{
System.out.print(b[p]+”\t”);
p++;
}
System.out.println();
}
System.out.println(“largest”+”=”+larger);
System.out.println(“Row : “+minr);
System.out.println(“Column : “+minc);
System.out.println(“smallest”+”=”+smallest);
System.out.println(“Row : “+maxr);
System.out.println(“Column : “+maxc);
}
}

——————-end—————————-




Share this:


EcoleBooks | ISC COMPUTER PRACTICAL PAPER 2012 SOLVED

subscriber

Leave a Reply

Your email address will not be published. Required fields are marked *

Accept Our Privacy Terms.*