C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 22nd, 2013, 12:36 AM
theotherstudent theotherstudent is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 theotherstudent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 51 sec
Reputation Power: 0
Homework Help pls

I need a bit of homework help for you programmers out there. I need to write a program for pelles ide to calculate current and power in a resistor what I have so far is

int main (void)
{
double resistance; /*Stores resisitance entered by user*/
double voltage; /*Stores voltage entered by user*/
double current; /*Stores current after calculation*/
double power; /*Stores power dissipation after calculation*/
double Watts; /*Stores current after calculation*/
double I; /*Value for power*/

printf("enter resistance: ohms");
scanf("%.3f, &resistance ohms");
printf("enter voltage: volts");
scanf("%.3f, *voltage volts");

/*Calculate current as current equals voltage divided by resistance*/
current = voltage / resistance;

/*Calculate power dissipation as power equals voltage times current*/
power = voltage * current;

/*Output voltage and resistance*/

printf("The current of a circuit with voltage and resistance %.3f is %.3f\n", Watts);
printf("The power in a circuit with voltage and current $.3f is %.3f\n", I);
return (0);
}

but I get errors
I:\School Work\resistor\resistor\resistor.c(30): warning #2233: Insufficient number of arguments to 'printf' according to the format string.
I:\School Work\resistor\resistor\resistor.c(14): warning #2116: Local 'Watts' is used without being initialized.
I:\School Work\resistor\resistor\resistor.c(15): warning #2116: Local 'I' is used without being initialized.

how do I fix?

Reply With Quote
  #2  
Old January 22nd, 2013, 01:02 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,382 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 34 m 6 sec
Reputation Power: 4080
You should learn to understand what your compiler is telling you. For instance:
"I:\School Work\resistor\resistor\resistor.c(30): warning #2233: Insufficient number of arguments to 'printf' according to the format string."
Here, when it says:
"I:\School Work\resistor\resistor\resistor.c(30)"
it is telling you that the error is in resistor.c close to line number 30.
Next, the actual error message:
"Insufficient number of arguments to 'printf' according to the format string."
What this is telling you is that in your printf() format string, you have multiple % arguments (you have two %.3f in there), but you don't have enough arguments after that (you only have Watts, which is a single argument).

Similarly, read the other error messages. They explain EXACTLY what mistakes you made and approximately where you made them.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Reply With Quote
  #3  
Old January 22nd, 2013, 02:28 AM
swapy swapy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 66 swapy Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 14 h 4 m
Reputation Power: 0
printf("The current of a circuit with voltage and resistance %.3f is %.3f\n", Watts);
printf("The power in a circuit with voltage and current $.3f is %.3f\n", I);


in both lines u used 2 format specifiers but supplied only one value ... u need to supply 2 values....

correction would be:
printf("The current of a circuit with voltage and resistance %.3f is %.3f\n", resistance,Watts);
printf("The power in a circuit with voltage and current $.3f is %.3f\n", I,Watts);

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Homework Help pls

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap