Answer to Question #283125 in C++ for Rasheed Osman

Question #283125

ii. Write a program in C++ with the following datatypes. Use the 3 different variables with the same data type. Explain the codes step by step.

a. int

b. float.

c. double. d. string. e. bool.


1
Expert's answer
2021-12-28T01:31:31-0500
#include<iostream>



using namespace std;



int main(){
    int a = 1;
    string b = "Hello";
    bool c = true;
    float d = 12.78;
    double e = 15.8776;



    cout << "The variable a is an int and its values is : " << a << endl;
    cout << "The variable b is a string and its values is : " << b << endl;
    // This give an ouptut of 1 because true = 1 and false = 0 for boolean
    cout << "The variable c is a boolean and its values is : " << c << endl;
    cout << "The variable d is a float and its values is : " << d << endl;
    cout << "The variable e is a double and its values is : " << e << endl;



    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog