Showing posts with label ISC computer science practical paper 2018 solved. Show all posts
Showing posts with label ISC computer science practical paper 2018 solved. 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();
}
}

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