C Programming Practical 3
C Programming Practical 3
Programming Lab
Problem Definition:
#include <stdio.h>
int main() {
float x, y;
scanf("%f", &x);
return 0;
}
OR
#include <stdio.h>
int main() {
float y, x;
if (x <= 2) {
y = 2.4*x + 3;
}
else {
y = 3*x - 5;
}
return 0;
}
Output :
Conclusion:
I n this practical we learnt about the use of conditional operators. conditional or ternary
operators are a concise way to express a condition in many programming languages. Here
we used if and if-else statements to evaluate the expression and get the desired output
according to it.