Question: C# Write a function solution that accepts two integers N1 and N2. The function should return a number based on following conditions: 0 if N1

C#

Write a function solution that accepts two integers N1 and N2. The function should return a number based on following conditions:

0 if N1 is 5 and N2 is 2.

1 if N1 is 5 and N2 is not 2.

2 if N1 is not 5 and N2 is 2.

3 if N1 is not 5 and N2 is not 2.

Use nested-if-else statement.

Input 5 4

Output 1

Here, N1 = 5 and N2 != 2. Hence, the result is 1 according to the given conditions.

Below is the partial code:

using System;

public class ProblemSolution { //Do not use standard input/ouput methods like Console.WriteLine()/Console.ReadLine() public int solution (int N1, int N2) { //write your code here } } class DriverMain { //Your program will be evaluated by this main method and several test cases.

public static void Main () { int N1, N2, result; ProblemSolution problemsolution = new ProblemSolution (); N1 = int.Parse (Console.ReadLine ()); N2 = int.Parse (Console.ReadLine ()); result = problemsolution.solution (N1, N2); Console.Write (result); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!