Recently Added Questions & Answers

 

import java.util.*;

 

public class Functions {

 

   public static int calculateProduct(int a, int b) {

      return a * b;

   }

 

       public static void main(String args[]) {

       Scanner sc = new Scanner(System.in);

       int a = sc.nextInt();

       int b = sc.nextInt();

       System.out.println(calculateProduct(a, b));

   }

}

 

​​import java.util.*;

 

public class Functions {

   public static void printFactorial(int n) {

       //loop

       if(n < 0) {

           System.out.println("Invalid Number");

           return;

       }

       int factorial = 1;

 

       for(int i=n; i>=1; i--) {

           factorial = factorial * i;

       }

 

       System.out.println(factorial);

       return;

   }

   public static void main(String args[]) {

       Scanner sc = new Scanner(System.in);

       int n = sc.nextInt();

 

       printFactorial(n);

   }

}

 

 

import java.util.*;

 

public class Functions {

 

   //Multiply 2 numbers

   public static int multiply(int a, int b) {

       return a*b;

   }

   public static void main(String args[]) {

       Scanner sc = new Scanner(System.in);

       int a = sc.nextInt();

       int b = sc.nextInt();

 

       int result = multiply(a, b);

       System.out.println(result);

   }

}

 


import java.util.*;

 

public class Strings {

   public static void main(String args[]) {

     StringBuilder sb = new StringBuilder("HelloWorld");

    

     for(int i=0; i

       int front = i;

       int back = sb.length() - i - 1;

 

       char frontChar = sb.charAt(front);

       char backChar = sb.charAt(back);

 

       sb.setCharAt(front, backChar);

       sb.setCharAt(back, frontChar);

     }

 

     System.out.println(sb);

   }

}

 

import java.util.*;

 

public class Strings {

   public static void main(String args[]) {

     Scanner sc = new Scanner (System.in);

     String email = sc.next();

     String userName = "";

 

     for(int i=0; i

       if(email.charAt(i) == '@') {

        break;

       } else {

         userName += email.charAt(i);

       }

     }

 

     System.out.println(userName);

   }

}

 

import java.util.*;

 

public class Strings {

   public static void main(String args[]) {

     Scanner sc = new Scanner (System.in);

     String str = sc.next();

     String result = "";

 

     for(int i=0; i

       if(str.charAt(i) == 'e') {

         result += 'i';

       } else {

         result += str.charAt(i);

       }

     }

 

     System.out.println(result);

   }

}

 

import java.util.*;

 

public class Strings {

   public static void main(String args[]) {

     Scanner sc = new Scanner (System.in);

     int size = sc.nextInt();

     String array[] = new String[size];

     int totLength = 0;

 

     for(int i=0; i

       array[i] = sc.next();

       totLength += array[i].length();

     }

 

     System.out.println(totLength);

   }

}

 

import java.util.*;

 

public class Arrays {

   public static void main(String args[]) {

      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      int m = sc.nextInt();

 

      int matrix[][] = new int[n][m];

      for(int i=0; i

           for(int j=0; j

               matrix[i][j] = sc.nextInt();

           }

      }

 

      System.out.println("The transpose is : ");

      //To print transpose

      for(int j=0; j

          for(int i=0; i

              System.out.print(matrix[i][j]+" ");

          }

          System.out.println();

      }

   }

}

 

import java.util.*;

 

public class Arrays {

   public static void main(String args[]) {

      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      int m = sc.nextInt();

 

      int matrix[][] = new int[n][m];

      for(int i=0; i

           for(int j=0; j

               matrix[i][j] = sc.nextInt();

           }

      }

 

      System.out.println("The Spiral Order Matrix is : ");

      int rowStart = 0;

      int rowEnd = n-1;

      int colStart = 0;

      int colEnd = m-1;

 

      //To print spiral order matrix

      while(rowStart <= rowEnd && colStart <= colEnd) {

          //1

          for(int col=colStart; col<=colEnd; col++) {

              System.out.print(matrix[rowStart][col] + " ");

          }

          rowStart++;

 

          //2

          for(int row=rowStart; row<=rowEnd; row++) {

              System.out.print(matrix[row][colEnd] +" ");

          }

          colEnd--;

 

          //3

          for(int col=colEnd; col>=colStart; col--) {

              System.out.print(matrix[rowEnd][col] + " ");

          }

          rowEnd--;

 

          //4

          for(int row=rowEnd; row>=rowStart; row--) {

              System.out.print(matrix[row][colStart] + " ");

          }

          colStart++;

 

          System.out.println();

      }

   }

}

 

import java.util.*;

 

public class TwoDArrays {

   public static void main(String args[]) {

       Scanner sc = new Scanner(System.in);

       int rows = sc.nextInt();

       int cols = sc.nextInt();

 

       int[][] numbers = new int[rows][cols];

 

       //input

       //rows

       for(int i=0; i

           //columns

           for(int j=0; j

               numbers[i][j] = sc.nextInt();

           }

       }

 

       int x = sc.nextInt();

 

       for(int i=0; i

           for(int j=0; j

               //compare with x

               if(numbers[i][j] == x) {

                   System.out.println("x found at location (" + i + ", " + j + ")");

               }

           }

       }

  }

}

Jump to Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

Recommended Question Bank

General - Computer Science
View
- Computer organisation and architecture
View
NA - Java
View
- javascript
View
- STORAGE AREA NETWORKS
View
Mejona - Mejona Technology
View
VTU - NCES(Non - Conventional Energy Resources
View
- Java Basic Codes
View
VTU - STORAGE AREA NETWORK
View
- HIGHWAY ENGINEERING
View
- COMPUTER ORGANIZATION
View
- Quantity Surveying and Contracts Management
View
- Design of RC Structural Elements
View
- Ground Water and Hydraulic
View
- Urban Transport Planning
View
- Basic Geotechnical Engineering
View
VTU - Municipal Waste Water Engineering
View
VTU - Design of Steel Structures Elements
View
- Interview Question Bank
View
VTU - Artificial Intelligence
View
Visvesvaraya Technological University (VTU) - Ground water hydraulic
View
-
View
VTU - Artificial intelligence and Machine Learning (AIML)
View
VTU - Energy and Environment
View
VTU - User Interface Design
View
- Data Structures and Algorithms
View
VTU - Big Data Analytics
View
VTU - Engineering Chemistry
View
VTU - User Interface Design (UID)
View
Entrance Exam for job - Entrance Exam Questions
View
VTU - Elements of Civil Engineering and Mechanic
View
VTU - Computer Graphics and Visualization
View
VTU - Object Oriented Concepts
View
VTU - System Software and Compiler Design
View
VTU - Web Technology and its Applications
View
VTU - Cloud Computing and Its Applications
View