Saturday, February 9, 2013

GOOD QUESTION FOR PRACTICAL EXAM



Numbers have different representations depending on the bases on which they are expressed.
For example in base 3, the number 12 is written as 110 (1*32 + 1*31 + 0*30),
but in base 8 it is written as 14 (1*81 + 4*80).
Consider, for example, the integers 12 and 5. Certainly these are not equal if base 10 is used for each. But suppose 12 was a base 3 number and 5 was a base 6 number then what happens, 12 base 3 = 1*31 + 2*30, or 5 base 6 or 5 base 10 (5 in any base is equal to 5 base 10). So 12 and 5 can be equal if you select the right bases for each of them.
Write a program to input two integers, X and Y, and calculate the smallest base for X and smallest base for Y (likely different from X) so that X and Y represent the same value. The base associated with X and Y will be between 1 and 20 (both inclusive). In representing these numbers the digits 0 to 9 have their usual decimal interpretations. The upper case alphabetic characters A through J represent digits 10 through 19 respectively.
Test your program for the following data and some random data.

SAMPLE DATA :
INPUT :
X = 12, Y = 5
OUTPUT : 12 (base 3) = 5 (base 6)

INPUT : X = 10, Y = A
OUTPUT : 10 (base 10) = A (base 11)

INPUT : X = 12, Y = 34
OUTPUT : 12 (base 17) = 34 (base 5)

INPUT : X = 123, Y = 456
OUTPUT : 123 is not equal to 456 in any base between 2 to 20

INPUT : X = 42, Y = 36
OUTPUT : 42 (base 7) = 36 (base 8)

Decimal to Roman number conversion

import java.util.*;
class dectoroman
{
    public static void main(String arg[])
    {
        Scanner ob = new Scanner(System.in);
        String R[ ]={"C", "XC", "L", "XL", "X", "IX","V", "IV","I"};
        int x[ ]={100,90, 50, 40, 10, 9, 5, 4, 1};
        int d, i;
        String t="";
        System.out.println("Enter an integer number ");
        d=ob.nextInt();
        for(i=0;i
<R.length;i++)

        {    
            while(d<=x[i])
            {
                d = d - x[i];
                t = t + R[i];
            }
        }
        System.out.println("Roman number is = "+ t);
    }
}

Monday, February 4, 2013

ISC Practical 2013 - Expected Questions

ISC Practical ( Expected )

1. Binary Conversions
2. Hamming Distance
3. Mobius function
4. Sorting Rows / Columns of 2D Array
5. Finding maximum and minimum value of a 2D Array
6. Reversing words of a sentence
7. Sorting of words of a sentence

ISC Practical 2013 - Expected Question

Two decimal numbers converted into binary and sum in binary form

import java.util.*;
class BinaryAdd
{
public int n,m,p,q,r;
public void input()
{
// two decimal numbers converted into binary
// and sum is also converted into binary
Scanner br = new Scanner(System.in);
System.out.println(" Input a number n");
n=br.nextInt();
System.out.println(" Input a number m");
m=br.nextInt();
}
public void calculate()
{
p=decbin(n);
q=decbin(m);
System.out.println("Binary value for " + n + " is " + p);
System.out.println("Binary value for " + m + " is " + q);
r=sumbin(m+n);
System.out.println("Sum of two binary number " + p + " and " + q + " is " + r);
}
public int decbin(int x)
{
int a,s=0, i=0;
while(x>0)
{
a=x%2;
s = s + (int)Math.pow(10,i)*a;
x=x/2;
i++;
}
return s;
}
public int sumbin(int x)
{
int a,s=0, i=0;
while(x>0)
{
a=x%2;
s = s + (int)Math.pow(10,i)*a;
x=x/2;
i++;
}
return s;
}
public static void main(String arg[])
{
BinaryAdd ob= new BinaryAdd();
ob.input();
ob.calculate();
}
}

ISC 2013 Practical - Expected Question

Sum of two Binary numbers

import java.util.*;
class BinarySum
{
public int n,m,p,q,r;
public void input()
{
// two binary numbers added by converting into decimal
// and sum then converted into binary
Scanner br = new Scanner(System.in);
System.out.println(" Input a binary number n");
n=br.nextInt();
System.out.println(" Input a binary number m");
m=br.nextInt();
}
public void calculate()
{
p=bintodec(n);
q=bintodec(m);
if(p== -1 || q== -1)
System.out.println("INVALID BINARY VALUE ");
else
{
System.out.println("Binary number " + n + " in decimal is " + p);
System.out.println("Binary number " + m + " in decimal is " + q);
r=sumbin(p+q);
System.out.println("Sum of two binary number " + n + " and " + m + " is " + r);
}
}
public int bintodec(int x)
{
int a,s=0, i=0;
while(x>0)
{
a=x%10;
if(a>1) return -1;
s = s + (int)Math.pow(2,i)*a;
x=x/10;
i++;
}
return s;
}
public int sumbin(int x)
{
int a,s=0, i=0;
while(x>0)
{
a=x%2;
s = s + (int)Math.pow(10,i)*a;
x=x/2;
i++;
}
return s;
}
public static void main(String arg[])
{
BinarySum ob= new BinarySum();
ob.input();
ob.calculate();
}
}

ISC Practical 2013 Expected Question

for Input N=5
Output : Given number 5
Combinations :
1 1 1 1 1
1 1 1 2
1 2 2
1 1 3
1 4
2 3


import java.io.*;
class numcombi
{
String str="";
int a=0;
int b=0;
public void combi() throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a number : ");
int num = Integer.parseInt(br.readLine());
System.out.println("Combinations :");
for(int i=1;i<=num/2;i++)
{
str="";
extract(num,i);
}
}
public void extract(int n, int m)
{
a=m;
str+=" "+a;
b=n-a;
System.out.println(str+" "+b);
if(b<=m)
{
return;
}
extract(b,m);
}
public static void main(String arg[ ]) throws IOException
{
numcombi obj= new numcombi();
obj.combi();
}
}

Monday, March 12, 2012

ISC Computer Science Theory Paper - Structure

ISC Computer Science Theory Paper

PART A
(Attempt all questions)
Ques 1. Questions based on Boolean Algebra, Prepositional Logic
(5 sub-parts * 2 = 10 marks)
Ques 2. Questions based on Array address calculation, Implementation of Stacks in Algebraic
expression, interface, dynamic binding, exception, computation complexity
Ques 3. Output question have 2 parts of 5 marks each (Atleast one based on recursion)

PART 2
Section A (Attempt any three questions)

Ques 4. Question based on K-Map along with logic gate circuit (1 SOP and 1 POS)
Ques 5. Question based situation - Draw truth table, Reduce using K-Map and draw logic circuit
Ques 6. Question based on Hardware - Half and Full Adder, Decoder, Encoder and Multiplexer
Ques 7. Question on Truth table, Prepositional logic and Laws of Boolean Algebra

Section B (Attempt any two questions)
Ques 8. Object passing / general programs
Ques 9. Strings / Array
Ques 10. Recursion

Section C (Attempt any two questions)
Ques 11. Inheritance
Ques 12. Stacks / Queue
Ques 13. Binary Tree (Tree traversal) and Algorithm on Linked List