CrazyEngineers
  • Please check this code

    Paramita

    Member

    Updated: Oct 26, 2024
    Views: 1.1K
    i have a question. my compiler is not working.thats why i am using online free compiler. so i cant understand properly is my code right or not. so please help me someone. i am posting my code:

    #include<stdio.h>

    main()
    {
    int numb_one;
    int numb_two;
    int ans=numb_one+numb_two;

    printf("Put no one:\n");
    scanf("%d",numb_one);
    printf("Put no two:");
    scanf("%d",numb_two);
    scanf("%d",ans);
    getchar();
    return 0;

    }
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • grsalvi

    MemberDec 27, 2012

    You have not used ampersand (&) in scanf.
    And in 3rd last line ,though code the statement is correct,but i believe you actually want to show the answer.
    In that case the 3rd last statement is : printf("%d",ans);
    Are you sure? This action cannot be undone.
    Cancel
  • [Prototype]

    MemberDec 27, 2012

    As well you're doing the addition operation even before assigning proper values to your variable. You've to first assign the values to your variables and then perform operation on them.
    Are you sure? This action cannot be undone.
    Cancel
  • Beginner

    MemberDec 27, 2012

    In order to read a value from the keyboard, you will need to specify an address.
    For example, say you need to store some value in the variable x, you'll have to specify
    scanf ("%d",&x);
    when this statement is executed, whatever the input is given, it is stored into x.
    To be more clear when to enter a value, you can specify a printf statement before the scanf as follows
    printf("enter a value for x");
    This will prompt you to enter a value for x. Hope you got it..
    Are you sure? This action cannot be undone.
    Cancel
  • ashwin sarangula

    MemberDec 27, 2012

    i think there are some online programming sources where you cannot give values from keyboard at the run time. in that cases ,you should remove the scanf statements and directly initialize the values to the variable.
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberDec 27, 2012

    Also, U r adding the values without initializing, the statement:
     int ans=numb_one+numb_two;
    should be after u have scanned both numbers, otherwise ur "ans" will not have sum of two numbers.😀
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register