AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C# Programming
Select the output for the relevant code set:
1.
staticvoid Main(string[] args)
2.
{
3.
int a =4, b =5, c =7, u =9;
4.
int h;
5.
h =(Convert.ToInt32(u < b))+(a + b--)+2;
6.
Console.WriteLine(h);
7.
Console.WriteLine(b);
8.
Console.WriteLine(u < b);
9.
}
12,15,0
11,4,False
11,15,0
12,4,False
Step 1: Convert.ToInt32(u < b)(Evaluate result as 9 < 5 which is false in nature.So, solution is converted from 'false' to '0').
Step 2: (a + b--) evaluated as 4 + 5 = 9 + 2 =11. Step 3: u < b evaluated as 'False' without being converted to '0'.
Output : 11 4 False
Select the output for the following set of Code :
int a =8, b =6, c =10;
int d = a * c *2/ Convert.ToInt32(Math.Pow((c - b), 2));
if(d ==(c = Convert.ToInt32(Math.Sqrt(a * a + b * b)))&& c ==10)
Console.WriteLine("figure is hypotenuse");
else
Console.WriteLine("figure is square");
Figure is square
Figure is hypotenuse
False
None of the mentioned
Solving the expression for ‘c’ we get c==10 in if first condition as (c == Convert.ToInt32(Math.Sqrt(a * a + b * b))). The logical condition when d == (c = 10) suits here . Similarly, going for second condition where c ==10 as ‘&&’ operator exists between both given condition and at last both are evaluated to true as c == 10. So, only first statement is executed. Output :Figure is square
Select the relevant output for the following set of code:
int a =4;
int b =5;
int c =6;
int d =8;
if(((a * b / c)+ d)>=((b * c + d )/ a))
Console.WriteLine("Line 1 - a is greater to b");
Console.WriteLine((a * b / c)+ d);
Console.WriteLine("Line 1 - a is not greater to b");
Console.WriteLine((b * c + d )/ a);
“Line 1 – a is greater to b” 11
“Line 1 – a is not greater to b” 9
Both are equal
Now, here in ‘if’ condition both conditions of parenthesis and hence evaluating operators based on parenthesis are tested. for expression : ((a * b / c) + d) Step 1 : (a*b/c) (Evaluating as 4*5/6 = 3) Step 2 : ( (a*b/c) + d ) (Evaluating (3 + 8 = 11)) Result : 11 for expression : (b * c + d )/ a Step 1 : (b*c + d) (Evaluating as 5*6 +8 = 38) Step 2: (b*c + d) / a (Evaluating as 38 / 4 = 9) Result : 9 The relational operator “>=” between both expressions check for largest figure and hence consecutively executes the if condition. Output : Line 1 – a is greater to b. 11
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies