-
beginner : help
hi
i have been doing a few tutorials teaching my self c, i have tried to experiment with one of the exercises i have done but the out come isnt what i want. this is my source code:
Code:
#include <stdio.h>
main ()
{
int total;
int a,b;
printf("enter number:" ,&a);
scanf("%d");
printf("enter 2nd number:" ,&b);
scanf("%d");
total = a + b;
printf(" the number is %d " ,total );
getchar();
return 0;
}
i want the the program so i can enter 2 numbers and it to display the sum of those two numbers. what is hapenning when i execute the program tho is, i can enter the two numbers but after that, the cmd prompt screen disappears.
can any one help me??
also any good links to web sites with more exercise to do wud be appreciated
thanks
munch114
-
-
You know what they say about horseshoes and handgrenades??? Well it usually won't apply with C (even worse: sometimes it does).
But good try. You have something backward, I don't know what you were thinking but this is what should be:
Code:
printf("enter number:");
scanf("%d",&a);
printf("enter 2nd number:");
scanf("%d",&b);
See the difference?
-
reply
lol thanks, i feel like a ryt idiot now hahahaha
cheers 4 the help
munch114