QANTLER TECHNOLOGIES – Fresher Interview Questions with Answers – Session – 2
This blog explains about QANTLER TECHNOLOGIES – Fresher Interview Questions with Answers – Session – 2. They are explained clearly well below :
We have already discussed about some questions in the previous blog . Some of the frequently asked questions are :
_______________________________________________________________________________
1. Find the maximum number in a given three number ?
-
import java.util.Scanner;
-
-
class Largest
-
{
-
public static void main(String args[])
-
{
-
int x, y, z;
-
System.out.println(“Enter three integers”);
-
Scanner in = new Scanner(System.in);
-
-
x = in.nextInt();
-
y = in.nextInt();
-
z = in.nextInt();
-
-
if (x > y && x > z)
-
System.out.println(“First number is largest.”);
-
else if (y > x && y > z)
-
System.out.println(“Second number is largest.”);
-
else if (z > x && z > y)
-
System.out.println(“Third number is largest.”);
-
else
-
System.out.println(“The numbers are not distinct.”);
-
}
-
}
____________________________________________________________________
2 . Write a program to get input until user gives q as a input and find the maximum number
- print(“Start entering numbers”)
sum=0
c=0
while 1:
num=int(input())
c=c+1
sum=sum+num
print(“Press q when you are done inputting the numbers or y to continue”)
m=input()
if m==’q’:
break
print(“Average”,sum/c)
print(“Sum”,sum )
____________________________________________________________________________
3. Write a program to get three inputs such as first number, second number and operator.based on given operator then perform the corresponding arithmetic operation
(eg:if operator given is’+’ then perform (firstnumber+ secondnumber) )
#include <stdio.h>
#include <conio.h>
void main()
{
int a, b, c;
char ch;
clrscr() ;
printf(“Enter your operator(+, -, /, *, %)\n”);
scanf(“%c”, &ch);
printf(“Enter the values of a and b\n”);
scanf(“%d%d”, &a, &b);
switch(ch)
{
case ‘+’: c = a + b;
printf(“addition of two numbers is %d”, c);
break;
case ‘-‘: c = a – b;
printf(“substraction of two numbers is %d”, c);
break;
case ‘*’: c = a * b;
printf(“multiplication of two numbers is %d”, c);
break;
case ‘/’: c = a / b;
printf(“remainder of two numbers is %d”, c);
break;
case ‘%’: c = a % b;
printf(“quotient of two numbers is %d”, c);
break;
default: printf(“Invalid operator”);
break;
}
getch();
}
____________________________________________________________________
REFERENCES :
QANTLER TECHNOLOGIES – Fresher Interview Questions with Answers – Session – 1
https://payilagam.com/blogs/qantler-technologies-fresher-interview-questions-with-answers-session-1/
https://www.programmingsimplified.com/java/source-code/java-program-largest-of-three-numbers
https://www.codesdope.com/discussion/take-integer-inputs-from-user-until-heshe-presses-/