Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- /// if
- #include <stdio.h>
- int main()
- {
- int num1, num2, num3;
- printf("Enter three numbers: ");
- scanf("%d %d %d", &num1, &num2, &num3);
- // Maximum calculation using only if statements
- if (num1 > num2 && num1 > num3)
- {
- printf("Maximum number is: %d\n", num1);
- }
- if (num2 > num1 && num2 > num3) {
- printf("Maximum number is: %d\n", num2);
- }
- if (num3 > num1 && num3 > num2) {
- printf("Maximum number is: %d\n", num3);
- }
- return 0;
- }
- */
- /*
- /// If-Else If-Else
- #include <stdio.h>
- int main()
- {
- int num1, num2, num3;
- printf("Enter three numbers: ");
- scanf("%d %d %d", &num1, &num2, &num3);
- if (num1 >= num2 && num1 >= num3)
- {
- printf("Maximum number is: %d\n", num1);
- }
- else if (num2 >= num1 && num2 >= num3) {
- printf("Maximum number is: %d\n", num2);
- }
- else {
- printf("Maximum number is: %d\n", num3);
- }
- return 0;
- }
- */
- /*
- /// Nested If
- #include <stdio.h>
- int main() {
- int num1, num2, num3;
- // Input
- printf("Enter three numbers: ");
- scanf("%d %d %d", &num1, &num2, &num3);
- // Maximum calculation using nested if-else statements
- if (num1 >= num2)
- {
- if (num1 >= num3) {
- printf("Maximum number is: %d\n", num1);
- }
- else {
- printf("Maximum number is: %d\n", num3);
- }
- }
- else {
- if (num2 >= num3) {
- printf("Maximum number is: %d\n", num2);
- }
- else {
- printf("Maximum number is: %d\n", num3);
- }
- }
- return 0;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement