-4

I was simply trying to add two numbers. Look at its weird way of taking input its should be doing 12+14 but its calculating 12+13

Here is the code:

#include <stdio.h>
int main(){
    int a , b,s;
    printf("enter num1");
    scanf("%d ",&a);
    printf("enter num2");
    scanf("%d ",&b);
    s = a+b;
    printf("sum of %d and %d is >>>>%d",a,b,s);
    return 0;
}

Here is the output:

enter num1 12
13
enter num2 14
sum of 12 and 13 is >>>>25
Process returned 0 (0x0)   execution time : 6.593 s
Press any key to continue.
Anuraj
  • 11
  • 1
  • idk why my program is taking input in such weird way help me out please . – Anuraj Aug 23 '23 at 17:23
  • 2
    All questions here should have all relevant information ***in the question itself as plain text***. Links can stop working at any time making questions meaningless. Code, data, or errors shown as images cannot be copy/pasted; or edited or compiled for further research and investigation. Can you [edit] this question, removing and replacing all links and images with all relevant information as plain text? All code ***must meet all requirements for a [mre]***. You'll find many other questions here, with a [mre], in plain text. Please use them as an example for how your question should look. – Sam Varshavchik Aug 23 '23 at 17:23
  • 4
    Please take the [tour] and read [ask]. – jonrsharpe Aug 23 '23 at 17:23
  • 1
    Please remove the trailing space in each `scanf` format string. See [What is the effect of trailing white space in a scanf() format string?](https://stackoverflow.com/questions/19499060/what-is-the-effect-of-trailing-white-space-in-a-scanf-format-string) The trailing whitespace in the `scanf()` format string tells it to filter *any amount* of whitespace, but the function won't know how much that is until you actually enter a non-whitespace character, and it won't see that until you press Enter for the second time. **Every character in the format string has a purpose**. – Weather Vane Aug 23 '23 at 17:29
  • 1
    If reopened, it would be closed as a duplicate. – Weather Vane Aug 23 '23 at 17:38

0 Answers0