/* Write a Java Program to input 10 integers in an integer array and print the second largest in java */ import java.util.Scanner; public class SecondLargest { public static void main (String[] args) { int [] numbers = new int [ 10 ]; Scanner input = new Scanner (System.in); // Input 10 integers System.out.println( "Enter 10 integers:" ); for ( int i = 0 ; i < numbers.length; i++) { numbers[i] = input.nextInt(); } // Find the second largest int largest = numbers[ 0 ]; int secondLargest = numbers[ 0 ]; for ( int i = 1 ; i < numbers.length; i++) { if (numbers[i] > largest) { secondLargest = largest; largest = numbers[i]; } else if (numbers[i] > secondLargest && numbers[i] != largest) { secondLargest = numbers[i]; } } // Print th...
Posts
- Get link
- X
- Other Apps

Program to calculate number of days from 1st January (ISC- 2001) import java.io.*; class ISC_PR_2001 { public static void main(String arg[ ]) throws IOException { int a[ ]={31,28,31,30,31,30,31,31,30,31,30,31}; int d,m,y,s,i; BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); s=0; System.out.println("Enter day : "); d=Integer.parseInt(br.readLine( )); System.out.println("Enter month : "); m=Integer.parseInt(br.readLine( )); System.out.println("Enter ...
- Get link
- X
- Other Apps
//Enter decimal values in Descending order in an array and search for a specific number. If it is found then print its index Number otherwise print Not Found import java.util.*; class binarySearch//Binary search Descending order { public static void main(String args[]) { Scanner ob=new Scanner(System.in); System.out.println("Enter No of Elements"); int n=ob.nextInt(); double ar[]=new double[n]; int i,ind=-1; System.out.println("Enetr Decimal values in Descending Order\n"); for(i=0;i<n;i++) { ar[i]=ob.nextDouble();//enter values in Descending order } System.out.println("Enetr SEARCH NUMBER in DECIMAL"); double sp=ob.nextDouble(); int beg=0,last=n-1,mid=0; while(beg<=last) { mid=(beg+last)/2; ...
- Get link
- X
- Other Apps
//Tech number 2025 = 20 +25 =45 * 45 =2025 //printing all 4 digit Tech numbers class tech { public static void main(String arg[]) { for(int i=1000;i<=9999;i++) { int cpy,fst,lst; cpy=i; lst=cpy%100; fst=cpy/100; int sq=(int)Math.pow((fst+lst),2); if(sq==cpy) System.out.print(i+"\t"); } } } /* Output: 2025 3025 9801 Press any key to continue . . . /*
- Get link
- X
- Other Apps
//Finding LCM of 3 Numbers of integer type import java.util.*; class lcm { public static void main(String arg[]) { Scanner ob=new Scanner(System.in); System.out.println("Enter 3 Numbers"); int a=ob.nextInt(); int b=ob.nextInt(); int c=ob.nextInt(); int i; for(i=1; ;i++) { if(i%a==0 && i%b==0 && i%c==0) break; } System.out.println("LCM is \t"+i); } } /* Input: Enter 3 Numbers 15 6 7 Output: LCM is 210 Press any key to continue . . . */
- Get link
- X
- Other Apps
//Dequeue /* A doubly queue is a linear data structure which enables the user to add and remove integers from either ends, i.e. from front or rear. Define a class Dequeue with the following details: [10] Class name: Dequeue Data members/instance variables: arr[ ]: array to hold up to 100 integer elements lim: stores the limit of the dequeue front: to point to the index of the front end rear: to point to the index of the rear end Member functions: Dequeue(int t): constructor to initialize the data members lim = t; front = rear = -1 void addfront(int val): to add integer from the front if possible else display the message (“Overflow from front”) voidaddrear(intval): to add integer from the rear if possible else display the message (“Overflow from rear”) int popfront(): returns element from front, if possible otherwise returns – 9999 int poprear(): returns element from rear, if possible otherwise returns – 9999 Specify the class Dequeue giving details of the constructor (int), void addfro...