In this copied program, I had to add the last line... scanf("%d",&c); in order for the program to stop so i could see the answer. Without this line, as soon as i hit enter after entering a second number, it cleared the program. Obviously, this is my first attempt at programming and any help would be appreciated. I know that I don't need this last line, but I feel something is missing...
include <stdio.h>
main()
{
int a,b,c;
printf("\nThe first number is ");
scanf("%d",&a);
printf("The second number is ");
scanf("%d",&b);
c=a*b;
printf("The answer is %d \n",c);
scanf("%d",&c);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There already is one in the Please Read thread. Next time I modify it,
I might move it right after the discussion of the Basic 3. And it is
covered in the offical FAQ and Adrian's FAQ
There are of course a certain fraction of users who will not look for
things like an FAQ before posting a question.
We have gone through issues where there will be a certain error, call it
XYZ that is occuring commonly, where we have a thread titled:
"IF YOU HAVE ERROR XYZ, READ THIS FOR DIRECTIONS"
Where people will post directly over it a thread titled "Getting
Error XYZ! Help!"
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In this copied program, I had to add the last line... scanf("%d",&c); in order for the program to stop so i could see the answer. Without this line, as soon as i hit enter after entering a second number, it cleared the program. Obviously, this is my first attempt at programming and any help would be appreciated. I know that I don't need this last line, but I feel something is missing...
include <stdio.h>
main()
{
int a,b,c;
printf("\nThe first number is ");
scanf("%d",&a);
printf("The second number is ");
scanf("%d",&b);
c=a*b;
printf("The answer is %d \n",c);
scanf("%d",&c);
Amazing how blind (and/or stupid or ?) we can be at times ... eh?
Naw - I wouldn't know.
Lightening strikes
;)
Wayne
Have you looked at the thread titled "Please Read Before Posting a Question"?
:)
Wayne
Since this seems to be the most frequent newbie question, it might be appropriate to have a special link to specifically address it?
There already is one in the Please Read thread. Next time I modify it,
I might move it right after the discussion of the Basic 3. And it is
covered in the offical FAQ and Adrian's FAQ
There are of course a certain fraction of users who will not look for
things like an FAQ before posting a question.
We have gone through issues where there will be a certain error, call it
XYZ that is occuring commonly, where we have a thread titled:
"IF YOU HAVE ERROR XYZ, READ THIS FOR DIRECTIONS"
Where people will post directly over it a thread titled "Getting
Error XYZ! Help!"
Wayne