Else-if ladder হলো মাল্টি-ওয়ে ডিসিশন লেখার সবচেয়ে সাধারণ পদ্ধতি।
সিনট্যাক্স
if (condition1)
stmt1;
else if (condition2)
stmt2;
...
else if (condition n)
stmtn;
else
stmt x;
ফ্লোचार্ট
(চিত্র উপস্থাপন করা সম্ভব নয়)
উদাহরণ প্রোগ্রাম: চারটি সংখ্যার মধ্যে সর্বোচ্চ খুঁজে বের করা
#include<stdio.h>
void main() {
int a, b, c, d;
printf("Enter the values of a,b,c,d: ");
scanf("%d%d%d%d", &a, &b, &c, &d);
if(a > b)
printf("%d is the largest", a);
else if(b > c)
printf("%d is the largest", b);
else if(c > d)
printf("%d is the largest", c);
else
printf("%d is the largest", d);
}
আউটপুট
Enter the values of a,b,c,d: 2 3 4 5 5 is the largest