Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- debug_program_on_simplest_way_v1.c
- Task from:
- Supriyo Das
- https://www.facebook.com/Sanu151
- in group
- Learn C Language Programming
- https://www.facebook.com/groups/c.programing/
- Question:
- Where is the error?
- Answer:
- Error is in:
- scanf("%d,%d",&x,&y);
- replace first , with blanko
- write
- scanf("%d %d",&x,&y);
- In fact, there is no mistake in your program.
- The following confused you
- scanf ("%d,%d", &x, &y);
- This function requires you to enter two numbers that are separated by commas.
- For example
- 3,4 and press enter.
- Try it.
- But you did the following (blank space between numbers):
- 3 4 and press enter.
- Try that too.
- It's good to learn how to find a bug in the program yourself.
- The simplest way is to display the values of the variables that interest you
- in the appropriate places in the program.
- Write the program like this and then try the input of the variables
- with a comma and with the space between them.
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- int MAX(int a, int b);
- int main()
- {
- int x,y,z;
- printf("Input 2 numbers : ");
- scanf("%d,%d",&x,&y);
- printf("\n\n In main() \t x = %d \t y = %d \n", x, y);
- z=MAX(x, y);
- printf("\n bigger number is %d\n",z);
- return 0;
- }
- int MAX(int a, int b)
- {
- int result;
- printf("\n\n In MAX() \t a = %d \t b = %d \n", a, b);
- if(a>b)
- {
- result=a;
- }
- else
- {
- result=b;
- }
- return result;
- }
Add Comment
Please, Sign In to add comment