Tag: Operators in C++

Exercise Program # 04 Operators in C++

Q: Develop a program that will convert the temperature from degree Celsius to degree Fahrenheit. User input the temperature in Celsius. The relation is F=5/9*C+32? Answer: #include <iostream.h> #include <conio.h> void main() { float Ctemp, Ftemp; cout<<“Enter the temperature in Celsius: “; cin>>Ctemp; Ftemp=(9/5)*Ctemp+32; cout<<endl<<“The temperature in Fahrenheit is: “<<Ftemp; getch(); }

Posted in: C++ Exercises

Exercise Program # 03 Operators in C++

Q: Write a program that calculates the memory size of variable of different data type? Answer: #include <iostream.h> #include <conio.h> void main() { char a; short b; int c; long d; float e; double f; long double g; cout<<“Size of a: “<<sizeof(a)<<” byte”<<endl; cout<<“Size of b: “<<sizeof(b)<<” bytes”<<endl; cout<<“Size of c: “<<sizeof(c)<<” bytes”<<endl; cout<<“Size of d: […]

Posted in: C++ Exercises

Exercise Program # 02 Operators in C++

Q: Write a program that will solve for the power dissipation of a resistor when the voltage across the resistor and the current in the resistor are known. The relationship for the power dissipation is: P=I^2*R? Answer: #include <iostream.h> #include <conio.h> void main() { float V, I, R, P; cout<<“Enter the voltage across the resistor: […]

Posted in: C++ Exercises

Exercise Program # 01 Operators in C++

Q : Write a program that will compute the area of a circle. The user must enter the radius of the circle. Use the following formula for area A=3.14*R^2? Answer : #include <iostream.h> #include <conio.h> void main() { const float PI=3.14; int radius; float area; cout<<“Enter the radius of the circle: “; cin>>radius; area=PI*(radius*radius); cout<<“The […]

Posted in: C++ Exercises

Arithmetic Operators In C++

In C++ language we have the usual arithmetic operators for addition, subtraction, multiplication and division. C++ also provides a special arithmetic operator which is called modulus. All these operators are binary operators which means they operate on two operands. So we need two values for addition, subtraction, multiplication, division and modulus.

Posted in: C++ Basics

Program Example # 01 For Arithmetic Operators in C++

Problem statement: Calculate the average age of a class of ten students. Prompt the user to enter the age of each student.

Posted in: C++ Basics

Examples of Expressions in C++

We have already seen the precedence of arithmetic operators. We have expressions for different calculations in algebraic form, and in our programs we write them in the form of C++ statements. Let’s discuss some more examples to get a better understanding.

Posted in: C++ Basics

Program Example # 02 For Arithmetic Operators in C++

Problem Statement: Write a program that takes a four digits integer from user and shows the digits on the screen separately i.e. if user enters 7531, it displays 7,5,3,1 separately.

Posted in: C++ Basics
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 .