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: 1530
Discussions: 200,508, Posts: 2,374,401, Members: 245,831
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? (1635)
FT HOOD attack: 7 killed 12 injured (67)
Review My Build (5)
HELP!!! What do you think of this s.. (16)
Looking for a graphic card that wil.. (30)
Assosiations (21496)
My 1st pc build (40)
Aero in Vista (7)
PC Modern Warfare 2: it's much wors.. (12)
core i7 extreme 975, nvidia 9400gt (9)
How to Ship a PC (16)
Building my first computer (13)
[F@H SPAM 11/1/09]New month . . . n.. (33)
slaving laptop drive (7)
Recent Discussions
windows 7 retail and rtm (1)
FAT32 to NTFS file system in Win2kpro (4)
Internet very slow since updating AVG.. (8)
Motherboards and my curse... (25)
Review My Build (5)
HELP!!! What do you think of this sys.. (16)
New Processor, Monitor will not turn .. (2)
2009 Build (4)
My 1st pc build (40)
Freezing During Music/Movies (1)
Windows Experience Index is screwed u.. (2)
ext. sound card laptop to stereo syst.. (2)
Remote Desktop via SSH and error mess.. (2)
Help and Support disappeared from my .. (0)
[F@H SPAM 11/1/09]New month . . . new.. (33)
Basic applications needed for "r.. (1)
core i7 extreme 975, nvidia 9400gt (9)
hard drive problem (2)
Win7 TrustedInstaller Permissions (2)
Speed up Win 7 boot time a bit (1)
Hard Drive test program (2)
wireless westell versalink model 327w (1)
New build 10 second reboot cycle! Won.. (3)
New Linksys Routers (2)
sometime power/Amber light (0)


All times are GMT -4. The time now is 06:33 AM.
TechIMO Copyright 2008 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