Below are the most commonly asked logical question in interviews for freshers and experience. you can find the questions like swapping the numbers, palindrome, Armstrong number, sum of the given numbers, swap the two numbers in the given array, etc.
Before going to Top interview question and answers. I am going to give some tricks to crack the logical interview question.
- Modules -->% it gives the remainder and
- By --> / it gives the coefficient
example :
no=6789;
- no%10 = it gives a reminder that means units place number
- no%10 is used to identify the units place number
- no/10 is used to delete the units places number
Below are the top interview question on integer and string arrays.
Integer Array Example Questions :
- Find the sum of the given individual numbers
- Find the sum of the Squares of the given individual numbers
- Find the sum of the Cubes of the given individual numbers
- Reverse the given Number
- Check the given number is Palindrome Number or not
- Check the Given Number is Armstrong or not
- Simple Array iteration of the integer Array
- Sum of the given Integer Array
- Simple Array iteration using read the size and entering the custom values
- Finding the Largest Number in the given Array Integer
- Finding the least Number in the given Array Integer
- Swap two numbers without using the third variable
- Swap the twp numbers using third variables
- Find the sum of even numbers and odd numbers in the given Array
- Find the count of even numbers and odd numbers in the given Array
- Find the First Largest Number and Second Largest Number in the Given Array
- Find the First Lowest Number and Second Lowest Number in the Given Array
- Program to swap the Minimum Value and Maximum Value in the given Array
String Arrays Example Questions :
- Reverse the given String
- check given string is palindrome or not
- write a program for replacing the "," with " "spaces
- write a program to replace the "," with "?" spaces
- write a program to count the number of Vowels and Consonants in the given array
- write the program to print the only Vowels count and Consonants count(remove duplicates)
- write the program from Lowercase to Uppercase
- write the program from Uppercase to Lowercase
- reverse the words in the given string
Find the sum of the given individual numbers
using System; using System.Collections.Generic; namespace ConsolePractice {
class Program
{
static void Main(string[] args)
{ int no = 7890; int r = 0; int sum = 0; for (int i = 0; i < 4; i++) { r = no % 10; // moduler is used to
identitify the units place sum = sum + r; no = no / 10; // by is used to
delete the units place } Console.WriteLine("sum of the given digits" + sum); Console.ReadLine();
}
} } |
---|
Find the sum of the Squares of the given individual numbers &
Find the sum of the cubes of the given individual numbers
using System; using System.Collections.Generic; namespace ConsolePractice {
class Program
{
static void Main(string[] args)
{ int no = 7895; int r = 0; int sum = 0; for (int i = 0; i < 4; i++) { r = no % 10; // moduler is used to
identitify the units place sum = sum + (r*r); // for suqres use 2 times reminders and for cubes use three time reminder no = no / 10; // by is used to
delete the units place } Console.WriteLine("sum of the given digits" + sum); Console.ReadLine();
}
} } |
---|
Reverse the given Number
using System.Collections.Generic; namespace ConsolePractice {
class Program
{
static void Main(string[] args)
{ Console.WriteLine("Enter number to reverse the
given number"); int no = int.Parse(Console.ReadLine()); int r = 0; int rev = 0; int noLength = no.ToString().Length; for (int i=0;i <noLength;i++) { r = no % 10; rev = (rev * 10) + r; no = no / 10; } Console.WriteLine("The Reverse Number is rev=
"+rev); Console.ReadLine();
}
} |
---|
Check the given number is Palindrome Number or not
using System; using System.Collections.Generic; namespace ConsolePractice {
class Program
{
static void Main(string[] args)
{ Console.WriteLine("Enter number to reverse the
given number"); int no = int.Parse(Console.ReadLine()); int r = 0; int rev = 0; int revNum = no; int noLength = no.ToString().Length; for (int i=0;i <noLength;i++) { r = no % 10; rev = (rev * 10) + r; no = no / 10; } if (revNum== rev) {
Console.WriteLine("The Reverse
Number is Palindrome rev= " + rev); } else { Console.WriteLine("Number is Not
Palindrome Number "); } Console.ReadLine();
}
} |
---|
Check the given number is Armstrong Number or not
using System; using System.Collections.Generic; namespace ConsolePractice {
class Program
{
static void Main(string[] args)
{ Console.WriteLine("Enter number to reverse the
given number"); int no = int.Parse(Console.ReadLine()); int r = 0; int cube = 0; int revNum = no; int noLength = no.ToString().Length; for (int i=0;i <noLength;i++) { r = no % 10; cube = cube + (r*r*r); no = no / 10; } if (revNum== cube) { Console.WriteLine("The Reverse
Number is Armstrong rev= " + revNum); } else { Console.WriteLine("Number is Not Armstrong Number
"); } Console.ReadLine();
}
} } |
---|
Post a Comment (0)