home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

there any mistake in my programme ?

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2078
Discussions: 200,919, Posts: 2,379,046, Members: 246,287
Old March 31st, 2003, 08:02 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Jul 2002
Posts: 27
there any mistake in my programme ?

hi .. ..

#include<stdio.h>

int main( )
{
float miles, gallons, total, average, counter;

total = 0.0;
counter = 0.0;
gallons = 0.0;
miles = 0.0;

printf("Enter the gallons used (-1 TO END): ");

scanf("%f", &gallons);

printf("Enter the miles driven: ");
scanf("%f", &miles);


while( gallons != -1)
{
counter ++;
total = miles / gallons + total;
printf("Enter the gallons ( -1 to end): ");
scanf("%f", &gallons);
printf("Enter the miles: ");
scanf("%f", &miles);

}

if(counter != 0)
{
average = total / counter;
printf("The overall average was %f",average);
}
else
printf("\n no gallons entered");

return 0;

}



i will wait your reply.
__________________
keep smile,,,
the life is short,,,
has2 is offline   Reply With Quote
Old March 31st, 2003, 11:26 PM     #2 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
I would say you have a mistake(s) in your program if you get an error whilst compiling it or it produces unexpected results. Do either apply?
Creosote is offline   Reply With Quote
Old March 31st, 2003, 11:42 PM     #3 (permalink)
Member
 
Join Date: Feb 2002
Posts: 161
scanf("%f", &gallons);
Now suppose I entered a string instead of a number ....
Martee is offline   Reply With Quote
Old April 1st, 2003, 05:05 PM     #4 (permalink)
Junior Member
 
Join Date: Jul 2002
Posts: 27
thank you all

yes ,, about the programme was none error ..

but the result what i get it was not correct so, i think in my programe some of mistake or fix the a avairable to get the correct result .


best regards,,
has2 is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2846)
Obama the Muslim (11)
Why is Khalid Sheikh Mohammed even .. (9)
Is the PSU I received dead? (10)
windows vista security holes (7)
Foreign voltage (10)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (9)
A good PSU? (10)
Dept. of HS: NSA 'Helped' Develop V.. (15)
Print spooler problem (10)
New Computer wont recognize XP disc (7)
Ideal cheap graph card for PC-Gamin.. (15)
EVGA 9800 gtx help with finding a g.. (8)
Recent Discussions
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Help getting around port 80 for camer.. (1)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (31)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
windows vista security holes (7)
Install XP pro and a Vista laptop ?? (9)
EVGA 9800 gtx help with finding a goo.. (8)
Modern Warfare For the PC (32)
Problem with speed step/turbo boost? (1)
monitor will not turn on at all, (0)
Modern Warfare 2: Who Bought It? (61)
World's largest Monopoly Game using G.. (330)
Print spooler problem (10)
SIS 740 and Widescreen (8)
Baffling Problem with my CPU/MoBo's. .. (0)
Display shows 3x5 inch in middle of s.. (0)
HIS HD5770 graphic card question (15)
Best file format to play on Windows H.. (0)
PSP Go bought in Japan (0)
Asus P4G8X Mobo (3)
Need hard disk drivers (4)
windows 7 internet problem (4)


All times are GMT -4. The time now is 06:45 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28