HEre is my C++ program I made.... first I will put the directions and then the program. I cant seem to compile it for some reason so can anyone tell me what I did wrong please!!
Write a C++ program that does the following. Besides #include <iostream>, you will need #include <string>. Call this program program1.cpp
1. declare a char
2. declare an int
3. declare a float
4. declare a double
5. declare a string
6. declare a bool
7. assign values to each of these (separate statements from the declarations above)
8. print each variable to the monitor followed by an endline
9. assign a char to your int variable
10. print out that variable with statement like: “here is my char stored in an int variable”.
11. for each variable, write a statement that will print it’s size to the monitor. The statement should say, “the size of x is: “ followed by variable, followed by an endline.
12. add the two ints together and divide the total by 2. Print that result to the screen with a statement like: “(x+y)/2 = “ followed by result and an endline.
#include <iostream>
#include <string>
using namespace std;
char()
int()
float()
double()
string()
bool()
{
char = 6
int = 2
float = 7
double = 10
string = 9
bool = 12
cout << char << endl;
cout << "the value of char is " << char << endl;
cout << int << endl;
cout << "the value of int is " << int << endl;
cout << float << endl;
cout << "the value of float is " << float << endl;
cout << double << endl;
cout << "the value of double is " << double << endl;
cout << string << endl;
cout << "the value of string is " << string << endl;
cout << bool << endl;
cout << "the value of bool is " << bool << endl;
cout << (char)int;
cout << "Here is my char stored in an int
variable"<<endl;
size of (int);
size of (char);
cout << size of (char) << endl;
char = size of (char);
size of (int);
size of (int);
cout << size of (int) << endl;
int = size of (int);
size of (int);
size of (float);
cout << size of (float) << endl;
float = size of (float);
size of (int);
size of (double);
cout << size of (double) << endl;
double = size of (double);
size of (int);
size of (string);
cout << size of (string) << endl;
string = size of (string);
size of (int);
size of (bool);
cout << size of (bool) << endl;
bool = size of (bool);
cout << "(x+y)/2 = " << (myint+myint2)/2 << endl;
return 0;
}