Showing posts with label ISC 2018 practical question. Show all posts
Showing posts with label ISC 2018 practical question. Show all posts

Tuesday, November 19, 2019

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2018 | QUESTION NUMBER 2 | Follow on youtube for more |





import java.util.Scanner;
public class qstn_2
{
public static void sort(int a[])
{
int temp = 0;
for(int i =0;i<a.length;i++)
{
for(int j =0;j<a.length;j++)
{
if(a[i]<a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}

for(int i =0;i<a.length;i++)
{
System.out.print(a[i]+" ");
}
System.out.println();
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the matrix size");
System.out.print(" M = ");
int m =  sc.nextInt();
System.out.print(" N = ");
int n = sc.nextInt();
int input[][]  = new int[m][n];

// boundary case
if(n<=2||n>=10||m<=2||m>=10)
{
System.out.println("MATRIX SIZE OUT OF RANGE");
System.exit(0);
}

System.out.println("Enter elements of the matrix");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
input[i][j] = sc.nextInt();
}
}
System.out.println("ORIGINAL MATRIX");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
System.out.print(input[i][j]+" ");
}
System.out.println();

}


int insert = 0;
System.out.println("\nMATRIX AFTER SORTING ROWS");
for(int i=0;i<m;i++)
{
int arr[] = new int[n];
for(int j=0;j<n;j++)
{
arr[insert++] = input[i][j];
}
sort(arr);
insert = 0;
}
sc.close();
}
}

Sunday, November 3, 2019

ISC COMPUTER SCIENCE QUESTION PRACTICAL PAPER 2018 | QUESTION NUMBER 3 | Follow on youtube for more |



import java.util.*;
public class qstn_3
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of words");
int n = sc.nextInt();

//To shift the command to next line as after an integer input when we take a string
        // input the command does not shift to next line and is rather skipped.
        //It does not read the newline character in your input created by hitting "Enter,"
sc.nextLine();

//Boundary cases
if(n<2 && n>9)
{
System.out.println("Invalid Input");
System.exit(0);
}
// word array
String s[] = new String[n];

// length array
int length[] = new int[n];

for(int i = 0;i<n;i++)
{

// taking the string input 
s[i] = sc.nextLine();



// length of each word stored in the array
length[i] = s[i].length();
}
int j = 0;
String k = "";
int flag = 0;

// infinite loop as we don't know the length of
// maximum word.
while(true)
{

// Running the loop for each word
for(int i = 0;i<n;i++)
{

// This will check if the length is not zero
if(length[i]!=0)
{

// We extract the character
char c = s[i].charAt(j);

//We store the character in the variable with a space
k = k+c+" ";

// We decrease the length
length[i]--;

// A check variable for exit condition
flag++;
}

// If there are no character, we just add two spaces.
else
{
k = k+"  ";
}
}
// We increase the character position
j++;

// Display of the words
System.out.println(k);

// Erasing the word for next loop
k="";

//Exit condition when no more character in any word
if(flag==0)
{
System.exit(0);
}

//Initializing the flag to zero for next loop
flag = 0;
}
}
}

ICSE COMPUTER SCIENCE SPECIMEN PAPER | QUESTION 7 | PLEASE DO WATCH THE VIDEO

  import  java.util.*; class icse_specimen_1 {     public static void main(String[] args)     {         Scanner sc1 = new Scanner(System.in)...