The reciprocal of y is 05 The reciprocal of z is 0333333 yz

The reciprocal of y is 0.5 The reciprocal of z is 0.333333 y/z is 0 y modulus z is 2 ladams .18450mrn-ecsappd01 labl]$ basics .exe Enter a character: 4. Enter value for double value x: 4.5 Enter value for integer value y 9 Enter value for integer value z: 8 Your character is 4 Your value for x is -4.5 T Your value for y is 9 Your value for Z is 8 The reciprocal of x is -0.222222 x/z is -0.5625 x y z is 12.5 The reciprocal of y is 0.111111 The reciprocal of z is 0.125 y/z is 1 modulus z is 1

Solution

//Program and output is given below

#include <iostream>

using namespace std;

int main()
{ //variable declaration
    char c;
    double x;
    int y,z;

// Prompt and accept input from user
   cout<<\"Enter a character: \";
   cin>>c;
   cout<<\"Enter a value for double value x: \";
   cin>>x;
   cout<<\"Enter a value for integer value y: \";
   cin>>y;
   cout<<\"Enter a value for integer value z: \";
   cin>>z;
   cout<<endl;

    //Print the values
   cout<<\"Your character is \"<<c<<endl;
   cout<<\"Your value for x is \"<<x<<endl;
   cout<<\"Your value for y is \"<<y<<endl;
   cout<<\"Your value for z is \"<<z<<endl<<endl;
   //calculate and print the values. double(x) is used for type casting to show proper output
   cout<<\"The reciprocal of x is \"<<(1/double(x))<<endl;
   cout<<\"x/z is \"<<(x/z)<<endl;
   cout<<\"x + y + z is \"<<(x+y+z)<<endl<<endl;
   cout<<\"The reciprocal of y is \"<<(1/double(y))<<endl;
   cout<<\"The reciprocal of z is \"<<(1/double(z))<<endl;
   cout<<\"y/z is \"<<(y/z)<<endl;
   cout<<\"y modulus z is \"<<(y%z)<<endl;

   return 0;
}

/*Output   Enter a character: 4                                                                                                                                                     Enter a value for double value x: -4.5                                                                                                                                   Enter a value for integer value y: 9                                                                                                                                     Enter a value for integer value z: 8                                                                                                                                     

                                                                                                                                                                  Your character is 4                                                                                                                                                      Your value for x is -4.5                                                                                                                                                Your value for y is 9                                                                                                                                                    Your value for z is 8                                                                                                                                                    

                                                                                                                                                                      The reciprocal of x is -0.222222                                                                                                                                         x/z is -0.5625                                                                                                                                                           x + y + z is 12.5                                                                                                                                                        

                                                                                                                                                                       The reciprocal of y is 0.111111                                                                                                                                          The reciprocal of z is 0.125                                                                                                                                             y/z is 1                                                                                                                                                                 y modulus z is 1 */                                                                                                                                                                  

 The reciprocal of y is 0.5 The reciprocal of z is 0.333333 y/z is 0 y modulus z is 2 ladams .18450mrn-ecsappd01 labl]$ basics .exe Enter a character: 4. Enter
 The reciprocal of y is 0.5 The reciprocal of z is 0.333333 y/z is 0 y modulus z is 2 ladams .18450mrn-ecsappd01 labl]$ basics .exe Enter a character: 4. Enter

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site