Thursday, 4 May 2017

Sum of Array Matirx in java

Printing Sum of array matrix using Scanner class:-

import java.util.Scanner;
public class arr_sum_matrix 
{
public static void main(String[] args) 
{
Scanner sc=new Scanner(System.in);
int a[]=new int[50];
int b[]=new int[50];
int c[]=new int[100];
int y,n;
System.out.println("ENTER FIRST SIZE OF YOUR ARRAY");
n=sc.nextInt();
for(y=0;y<n;y++)
{
a[y]=sc.nextInt();

}
System.out.println("THE FIRST ARRAY IS :");
for(y=0;y<n;y++)
{
System.out.println(a[y]);
}
System.out.println("ENTER SECOND SIZE OF YOUR ARRAY");
n=sc.nextInt();
for(y=0;y<n;y++)
{
b[y]=sc.nextInt();
}
System.out.println("THE SECOND ARRAY IS \n");
for(y=0;y<n;y++)
{
System.out.println(b[y]);
}
for(y=0;y<n;y++)
{
c[y]=a[y]+b[y];
System.out.println("THE SUM OF ARRAY IS:"+c[y]);
}
}
}

In this program we used three arrays a,b,c. Array a contain some values which is inserted by the user,Array b contains some values which is also inserted by the user.Array c is used to store the sum of values of array a and array b.
If we talk about the flow of our program first it will ask the user to set size of your first  array ,after setting the size of your array, you will ask to insert values for your first array.Similarly it will ask to setting size of second array and inserting second array values.
After after these it will print the values of sum of these two arrays.You can set any no. of size for your array.For better understanding copy this code and implement it.

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...