প্রথমে, তিনটি সংখ্যা সেট করা যাক −
int num1, num2, num3; // set the value of the three numbers num1 = 10; num2 = 20; num3 = 50;
এখন দ্বিতীয় সংখ্যার সাথে প্রথম সংখ্যাটি পরীক্ষা করুন৷ যদি num1> num2 হয়, তাহলে num3 দিয়ে num1 চেক করুন। যদি num1 num3-এর থেকে বড় হয়, তার মানে হল বৃহত্তম সংখ্যা হল num1৷
উদাহরণ
আপনি সর্বাধিক তিনটি সংখ্যা খুঁজে পেতে নিম্নলিখিত কোডটি চালানোর চেষ্টা করতে পারেন৷
৷using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
class MyApplication {
static void Main(string[] args) {
int num1, num2, num3;
// set the value of the three numbers
num1 = 10;
num2 = 20;
num3 = 50;
if (num1 > num2) {
if (num1 > num3) {
Console.Write("Number one is the largest!\n");
} else {
Console.Write("Number three is the largest!\n");
}
}
else if (num2 > num3)
Console.Write("Number two is the largest!\n");
else
Console.Write("Number three is the largest!\n");
}
}
} আউটপুট
Number three is the largest!