Help me in solving LJAJAG31 problem

My issue

solution give me

My code

#include <stdio.h>

void findMaxMin(int num1, int num2, int *max, int *min) {
   if (num1 > num2)
      *max = num1;
      *min = num2;
    }else{
         *max = num2;
         *min = num1;
    }
}

int main() {
    int num1, num2, max, min;

    scanf("%d %d", &num1, &num2);
    
    fidMaxMin(num1, num2, &max, &min);

    printf("Max: %d\n",max);
    printf("Min: %d\n",min);

    return 0;
}

Learning course: Learn C Programming
Problem Link: https://www.codechef.com/learn/course/rcpit-programming-c/RCPITLPC37/problems/LJAJAG31

function calling spelling is wrong

Your code contains several issues, which I’ll address step by step.

Issues in Your Code:

  1. Typo in Function Call:
  • You’ve written fidMaxMin instead of findMaxMin in the main function.
  1. Improper Braces in if-else:
  • Your if-else block in the findMaxMin function is missing proper braces around the if block. This causes a syntax error or unexpected behavior.
  1. Missing Header Comments or Clarity:
  • Adding clarity with comments can help you and others understand the code better.

Corrected Code:

c

Copy code

#include <stdio.h>

// Function to find the maximum and minimum of two numbers
void findMaxMin(int num1, int num2, int *max, int *min) {
    if (num1 > num2) {
        *max = num1;
        *min = num2;
    } else {
        *max = num2;
        *min = num1;
    }
}

int main() {
    int num1, num2, max, min;

    // Taking input from the user
    scanf("%d %d", &num1, &num2);

    // Calling the function with correct name
    findMaxMin(num1, num2, &max, &min);

    // Printing the results
    printf("Max: %d\n", max);
    printf("Min: %d\n", min);

    return 0;
}

Explanation of Fixes:

  1. Fixed Function Call:
  • Changed fidMaxMin to findMaxMin in the main function.
  1. Corrected if-else Braces:
  • Added braces {} for both the if and else blocks in the findMaxMin function. This ensures proper grouping of statements.
  1. Improved Readability:
  • Added comments to explain the code better.

Example Input/Output:

Input:

Copy code

5 10

Output:

makefile

Copy code

Max: 10
Min: 5

Try running this corrected code, and it should work as expected!