By 26/03/2014 10 Comments

Exercise # 04 Decision Making Statements in C++

Q: Develop a C++ program which will compute the power dissipation of a resistor, when the user inputs current value and the resistance. Program warns the user if power dissipation is above 1 watt. The power dissipation is measured by P=I2R.

Answer:

#include <iostream.h>
#include <conio.h>

void main()
{
     float varP, varI, varR;

     cout<<"Enter the resistance: ";
     cin>>varR;
     cout<<"Enter the current through the resistor: ";
     cin>>varI;

     varP=(varI*varI)*varR;
     cout<<"the power dissipation is "<<varP<<" watts"<<endl;

     if(varP>1)
     cout<<"Alert! There is too much power dissipation";

     getch();
}






Posted in: C++ Exercises

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .