Please check this code

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

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;

}

Replies

  • grsalvi
    grsalvi
    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);
  • [Prototype]
    [Prototype]
    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.
  • Beginner
    Beginner
    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..
  • ashwin sarangula
    ashwin sarangula
    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.
  • rahul69
    rahul69
    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.😀

You are reading an archived discussion.

Related Posts

Hi CEans this is arathana studying ECE first year.I want to make myself technical with the help of CEans.
HI...I'm pursuing 1st year civil engineering.I'm proud to become an engineer and also very proud to be an (civil) engineer..world is coming to no more condition without civil engineer...right ???In...
which is the most popular company that civil engineers can work?
please suggest me that which book would i choose for FOC and ENGINEER GRAPHICS? and also how can i do E.G during examination?
In bikes there are 120 cc,80 cc....What does cc mean?