Skip to main content

Posts

Showing posts with the label tcs digital preparation

Mission "TCS DIGITAL" ( Upgrade Ninja to Digital ) previous year Coding Quistion 06

  Problem Statement :  Subscribe the channel :  click here Q--> Write a program to take a number as input and find that if square number, then last digit of the number is equal to same as input number . Approach :  1. Take a Integer as input  2. Square the number  3. and check the condition Code : import java . util .*; public class JAVA36 {     public static void main ( String [] args ) {         Scanner sc = new Scanner ( System . in );         int n = sc . nextInt ();         int sqr = n * n ;         int d = sqr % 10 ;         if ( d == n ){             System . out . println ( "Correct Number !" );         }         else {             System . out . println ( "Incorrect number !" );         }     } ...

Mission "TCS DIGITAL" ( Upgrade Ninja to Digital ) previous year Coding Quistion 05

  Problem Statement :  Subscribe the channel :  click here Q--> Write a program to find Nth smallest element from Array . Approach :  1. Number of element you want to store array . 2. Store element in array as a unsorted manner  3. find the  element at Nth smallest element  Code : import java . util .*; public class JAVA35 {     public static void main ( String [] args ) {         Scanner sc = new Scanner ( System . in );         System . out . println ( "Enter your length of array : " );         int n = sc . nextInt ();                 int arr []= new int [ n ];         for ( int i = 0 ; i < arr . length ; i ++){             arr [ i ]= sc . nextInt ();         }         System . out . println ( "Array ELements are : " );     ...

Mission "TCS DIGITAL" ( Upgrade Ninja to Digital ) previous year Coding Quistion 04

 Problem Statement :  Subscribe the channel :  click here   Given an array Arr[ ] of N integers and a positive integer K. The task is to cyclically rotate the array clockwise by K. Note  : Keep the first of the array unaltered.   Example 1: 5  —Value of N {10, 20, 30, 40, 50}  —Element of Arr[ ] 2  —–Value of K Output : 40 50 10 20 30 Example 2: 4  —Value of N {10, 20, 30, 40}  —Element of Arr[] 1  —–Value of K Output : 40 10 20 30 code :   import java.util.*; public class rotate {     public static void main( String [] args) {         Scanner sc= new Scanner(System.in);         int n=sc.nextInt();         int arr[]= new int [n];         for ( int i= 0 ;i<arr.length;i++){             arr[i]=sc.nextInt();         }         int k=sc.nextInt();   ...

Mission "TCS DIGITAL" ( Upgrade Ninja to Digital ) previous year Coding Quistion 03

  Problem Statement :  Click here to Subscribe :  Education inTalk Q3 . Find the number of students whose height is less than the height of their adjacent students. Problem Statement :  A physical education teacher asks students to assemble in a straight line for the morning assembly.Given an array of N in which each element represents the height of the student in that position. The task here is to find the number of students whose height is less than the height of their adjacent students. Input: 35, 15, 45,25,55  Output: 2 (35>15<45 and 45>25<55) Explanation :  we take element at index 1 start checking the condition and those who satisfied the condition , will be our output . [ there is no mean to take 1st and last element into the iteration as there are no adjacent element of both side ] Code :  public class Problem3 {     public static void main( String [] args) {                 in...

Mission "TCS DIGITAL" ( Upgrade Ninja to Digital ) previous year Coding Quistion 02

  Problem 2 :  Subscribe Please :  click here Q2 : Sum of the digits of the given positive integer number N is UNO or not. Problem Statement :  Given a positive integer number N, reduce the number of digits of N by computing the sum of all the digits to get a new number. If this new number exceeds 9, then sum the digits of this new number to get another number and continue this way until a single digit value is obtained as the ‘digit sum’. The task here is to find out whether the result of the digit sum done this way is ‘1’ or not. If the result is 1 return UNO else not. Input : 254 output : not Input : 235 output : UNO Explation : 1. 254 = 2+5+4 = 11  2. 11>9 3. 11 = 1+1 = 2 4. 2<9 but not 1 so  5. output "NOT" 1. 235 = 2+3+5 =10 2. 10>9 3. 10 = 1+0 = 1 4. 1<9 and sum=1 so 5. output "UNO" Code :  import java.util.Scanner; public class Problem2 {     public static void main( String [] args) {         ...

Mission "TCS DIGITAL" ( Upgrade Ninja to Digital ) previous year Coding Quistion 01

 Problem 1 : Subscribe the channel :  Click here Q1 .  An automobile company manufactures both a two wheeler (TW) and a four wheeler (FW). A company manager wants to make the production of both types of vehicle according to the given data below: 1st data, Total number of vehicle (two-wheeler + four-wheeler)=v 2nd data, Total number of wheels = W The task is to find how many two-wheelers as well as four-wheelers need to manufacture as per the given data. Example : Input : 200  -> Value of V 540   -> Value of W Output : TW =130 FW=70 Explanation: 130+70 = 200 vehicles (70 *4)+(130* 2)= 540 wheels Constraints : 2<=W W%2=0 V <W Print “INVALID INPUT” , if inputs did not meet the constraints. The input format for testing The candidate has to write the code to accept two positive numbers separated by a new line. First Input line – Accept value of V. Second Input line- Accept value for W. The output format for testing Written program code should generate tw...