English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
#include
void main();
{
int a,b,c;
clrscr();
printf("enter the values for a and b\n");
scanf("%d%d",&a,&b);
c=a*b;
printf("product is %d",c)
getch()
}

2006-09-29 22:28:25 · 6 answers · asked by syedyaseen007 2 in Computers & Internet Programming & Design

6 answers

c=a*b;
printf("product is %d",c);
getch();

2006-09-29 22:31:42 · answer #1 · answered by Hades et Persephone 7 · 0 0

Don't know what the getch() is trying to accomplish, otherwise it should work. When trying to figure out what is going on, either: put in copious quantities of print statements (eg after ever line); or, BEST OF ALL, use a debugger. Start the program up in your debugger, and go through it STEP BY STEP (line by line), checking the values of the variables after each step. That (in the debugger) is where a programmer spends over 50% of their time, so, make yourself at home there.
========
#include

int main() {
int a,b,c;
printf("enter the values for a and b\n");
scanf("%d%d",&a,&b);
c=a*b;
printf("product is %d",c);
}

=======
$ ./a.exe
enter the values for a and b
5
6
product is 30

2006-09-30 05:43:07 · answer #2 · answered by michael 4 · 0 0

/*Make sure you give a seperator for getting the values of a and b */
scanf("%d %d", &a, &b);
c=a*b;
/* ; is missing */
printf("product is %d", c);
/* ; is missing */
getch();

Enjoy :)
Selva.

2006-09-30 05:37:28 · answer #3 · answered by njselvakumar 1 · 0 0

your scanf function is wrong,

check if a and b is getting the proper values.

put the line .......printf("%d %d, a,b )

to check the values for a & b.

happy programming..........

2006-09-30 05:33:37 · answer #4 · answered by shahjigu 2 · 0 0

how did u give input??
it should be given as
space
u should not press enter between the values of a and b...
Try this....

2006-09-30 05:34:36 · answer #5 · answered by naga 1 · 0 0

u did not end getch() with ";". type getch();

2006-09-30 05:41:03 · answer #6 · answered by one_man_show_14 2 · 0 0

fedest.com, questions and answers