1.
#include <iostream> using namespace std; int main() { double Tc,velocity;// Declaring variables cout<<"Enter the temperature: "; // Asking for user input cin>>Tc; velocity = 331.3+0.61*Tc;// Calculating velocity // Printing output cout<<"At "<<Tc<<" degrees Celcius the velocity of sound is "<<velocity<<" m/s."; return 0; }
2.
Expression | Result |
3+4-5 |
=7-5 =2 |
4+4*3/6 |
=4+12/6 =4+2 =6 |
6+12*2-8 |
=6+24-8 =30-8 =22 |
6+12*(2-8) |
=6+12*(-6) =6-72 =-66 |
(19-3)*(2+2)/4 |
=16*4/4 =64/4 =16 |
3.
cin>>myString1; would read single word till space.
cin.get(myChar1); would read character after "This" which is space here.
cin>>myChar2; would read single character 'i'
getline(cin,myString2); would read rest of the line.
myString1 | myChar1 | myChar2 | myString2 |
This | single space | i | s my first C++ program |
Intreductien: This assignment helps you to reinforce the topics discussed in the class including a) Variables...