
What is the difference between if and ladder if ? Describe ladder if with example. What is the purpose of the parameter passing ? please Describe with example.

if statement is used to write conditional expressions. If the given condition is true then it will execute the statements. Otherwise it will execute optional statements.
syntax:
if<conditon>
{
-----
-----
}
While in ladder-if, conditions are evaluated from Top to Bottom. As soon as TRUE expression is found the statement associated with it is executed and rest of the ladder is Bypassed.
syntax:
if(condition-1){
statement-1
}
else if(condition-2){
statement-1
}
else{
statement-2
}
Example of ladder if:
#include <stdio.h>
main()
{
int a,b,c;
printf("enter values for a,b,c");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
printf("%d is big",a);
else if(b>c)
printf("%d is big",b);
else
printf("%d is big",c);
}
Parameter Passing is used to provide extra flexibility to a program.
#include<stdio.h>
void f(int n) {
printf("d",n);
}
void main() {
int x = 2;
f(x);
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.