473,320 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

It doesn't give the product?? what could be the problem?

Hi! I'm new in turbo C... and I'm trying to make a Program to calculate the product of two numbers.
please help me! I'm using Turbo C v3.0

problem:
when I hit enter for the answer it doesn't give the product, the program closed.... :(

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h> 
  2.  
  3. int a, b, c;                                                                 
  4. int product (int x, int y);                                                   
  5.  
  6. main()                                                                        
  7. {                                                                            
  8. //input first number                                                          
  9. printf("enter a number between 1 and 100: ");                               
  10. scanf("%d", &a);                                                                                                              
  11.  
  12. //input second number                                                         
  13. printf("enter another number between 1 and 100: ");                           
  14. scanf("%d", &b);                                                              
  15.  
  16. c = product(a, b);                                                            
  17.  
  18. printf ("%d times %d = %d\n", a, b, c);                                   
  19.  
  20. return 0;
  21. }                                                        
  22.  
  23. int product( int x, int y)                                                   
  24.  
  25. {                                                                             
  26. return (x * y);                                                               
  27. }                                                       
  28.  
Aug 13 '11 #1
4 1592
weaknessforcats
9,208 Expert Mod 8TB
Your pogram is working. However, after your answer displays, the program races on to finish main() and stop before your eyes blink.

You need to add a phony data entry statement at the end of main() to stop the program until you press enter. This will allow you to read the answer.
Aug 13 '11 #2
what is a phony data entry statement?
Aug 13 '11 #3
weaknessforcats
9,208 Expert Mod 8TB
Just do a scanf at the end of main to stop the program for you to enter data. That will allow you time to see your result. Then press enter to complete the program execution.
Aug 14 '11 #4
thanks a lot! really big help ;)
Aug 16 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: anil | last post by:
Hi! I was installing Visual Studio .Net to my new computer. I've never installed any product of Visual Studio before to this computer. In the screen where I should enter my product key, which came...
10
by: Sabin Finateanu | last post by:
Hi! I have this method that gets the OS suite and product type, but it is always returning null. Can anyone help me, please? Here is the method and other necessary code: private struct...
0
by: Mike | last post by:
Hi All, I am using a COM object and so I have to use a form for it to work. The problem is I need to run it as a service as well. When I run it in a test scenario everything works fine and...
1
by: Hari Sekhon | last post by:
Hi, I'm wondering if anyone can please help me on figuring out a better way of doing an excepthook. I have a script which is using an excepthook to catch any uncaught exceptions - there usually...
2
by: ChrisNightingale | last post by:
Hi everybody, I have an odd issue which I'm not sure how to resolve. I'm basically implementing a print mechanism which takes a series of controls and reproduces them on a print document. So...
1
by: kccoolrocks1981 | last post by:
I need to create a temporary table in VBA Code but recordset.fields(i).Type gives me an integer value instead of the required field's Type. For an example Field_Name= "CriteriaName" and it's...
0
by: nityaprashant | last post by:
hello.. i had done below logic again.. but it doesn't give selected row's product name. it's gives all row's product name...particularly last row's product name.. i need selected row's...
2
by: neamtzu | last post by:
Hello. I have the following function: function delProd(codproddel, rowNr) { var agree=confirm("Esti sigur ca vrei sa stergi produsul?"); if (agree) { var elTRdel = $('produse').insertRow( -1...
2
by: Andy B | last post by:
I installed asp.net futures after installing vs2008. I can't find the "asp.net ajax futures enabled web application" template. How do I get my ajax templates back? Come to find out actually, all...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.