Skip to main content

Posts

Showing posts from February, 2020

Repotation.com Programming Question in java || Logical Question in Written Test

All Programming Question in Written test  Repotation.com ===============================================================================================================================================  Q.1- ============   Input: 9876565  Expected Output is: 1 Hint:9+8+7+6+5+6+5=10 =1  Input is Possitive Number Only. Coading Part:        //Q.1 import java.util.Scanner; class ClassA  {    public static void main(String[] args)  { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int sum=0,rem=0; while(true){ sum=0;            while(n!=0){              rem=n%10; sum=sum+rem; n/=10;    }    if(sum<10){               System.out.println(sum); break;   }   n=sum; } } } ====================================================================== Q.2- =========== Input :"for{do{print}}" Output: balanced Input:"while{do}a=5}"  Output:Unbalanced Coading Part:

#interviewQuestion #Writen How to find Which number having more fac...

Interview Question in java ------------------------------------------------------------------------------------------ Can you write a code to find the     maximum factor having 1 t0 10,000    whic number and how much factor.   ===================================   1--1   2--2   3--2   4--3   5--2   6--4   ----   ----   10,000-? Coding part: class LogicFindFactor  {    public static int factor(int n){          int count=0; for(int i=1;i<=n;i++){        if(n%i==0)    ++count;    }   return count;     } public static void main(String[] args)  { int arr[]=new int[10000]; for(int i=0;i<10000;i++){            arr[i]=factor(i+1); } int max=arr[0],number=0; for(int i=0;i<10000-1;i++){            if(max<arr[i+1]){               max=arr[i+1]; number=i+1;    } } System.out.println("Number:"+number);         System.out.println("Factor:"+max);  } }

Insertion sort logical Question || Interview Question in java ||Insertion sort algoritham

Insertion sort   algorithms || logical Question || Interview Question ================================================================== /*     Inserction in Arrays -------------------------------------------------------------- 1.first you have a one take one Arrays And store the element in the Arrays 2.you have to applay the logic to sort the arrays Assending array 3.so start thre loop of the Array 1 to lsat */ import java.util.Scanner; class  InsertionArrays { public static void main(String[] args)  { Scanner sc=new Scanner(System.in); //Take input how much element do you want to store in the Arrays System.out.println("Enter How much Number do you want to insert::"); int n=sc.nextInt(); //create Arrays based on the N values int a[]=new int[n]; //Display the Message how much number user have to insert System.out.println("Enter "+n+" element:"); //take all the user element in through the loop

Write a program to arrange all even number in left-side and odd number in right-side|| interview Question

Write a program to arrange all even number in left-side and odd number in right-side|| interview Question. ======================================================== import java.util.Scanner; class EvenOddArrange  { public static void main(String[] args)  { //Take the from the user for this class in java like the Scanf Scanner sc=new Scanner(System.in); //How many element do you want to insert in the arrays System.out.println("How many element in Arrays:"); int n=sc.nextInt();         //Create the Arrays based on the N vallues int arr[]=new int [n]; //Insert the element in arrays System.out.println("Enter "+n+" element:"); for(int i=0;i<n;i++){          arr[i]=sc.nextInt(); } //applay the logic to arrange the even and odd number in one side int i=0; int j=n-1; int temp; while(i<j){             //System.out.println("Hello");     //If number is odd while(true){              

How to remove or delete the element in arrays || interview Question in TCS company

How to delete or remove the element in array || Interview Questions in java. ========================================== import java.util.Scanner; class RemovedAElement  { public static void main(String[] args)  { Scanner sc=new Scanner(System.in); System.out.println("Enter How many element to insert:"); int n=sc.nextInt(); System.out.println("Enter "+n+" element:"); //Create the element based on the n int arr[]=new int[n]; //Insert element in arrays          for(int i=0;i<arr.length;i++){           arr[i]=sc.nextInt(); } //Take the values you have to delete and removed System.out.println("Enter number to removed:"); int val=sc.nextInt();        //applay the logic to removed the element in arrays      boolean found=false;      for(int i=0;i<arr.length;i++){                //check the values it is avilabled in the arrays or not    if(arr[i]==val){    //if values is matched than

How to reverse the element in arrays|| Best way to reverse the Arrays Element in Array

How to reverse the elements in arrays|| it is one of the best way to reverse the Array. =================================== import java.util.Scanner; class ReverseArrays  { public static void main(String[] args)  { Scanner sc=new Scanner(System.in); System.out.println("Enter the Number:"); int n=sc.nextInt(); //Make the array based on the n values int arr[]=new int[n]; //insert element in array System.out.println("Enter "+n+" element :"); for(int i=0;i<arr.length;i++){           arr[i]=sc.nextInt(); } //Apply the logic to reverse the Array element int i=0; int j=arr.length-1; int temp; while(i<j){            temp=arr[i];    arr[i]=arr[j];    arr[j]=temp;    i++;    j--; }       System.out.println("Array Reverse Number:");       for(int s=0;s<arr.length;s++){          System.out.print(arr[s]+" ");   } System.out.println(); } } outpu: ---------

Pattern Program in interview || How to do pattern programming very fast

Pattern Programming in java =======================================================================  It is one of the pattern Printing program so, many interviewer are asking these problem in java interview           Can you print this Pattern =========================== 1               2  6               This the gap of number -4 3  7  10                                                   -4,3   4  8  11  13                                              -4,3,2 5  9  12  14  15                                         -4,3,2,1 ------------------------------------------------    You have to print Like that pattern     x=1,2,3,4,5 y=x=1,2,3,4,5 Coding program of this Above program =============================    class Pattern{    public static void main(String args[]){    //int a=0;    for(int i=1;i<=5;i++){           for(int j=i,a=4,p=i;j>=1;j--,p=p+a,a--){             System.out.print(p+" ");                 }