It tells the coder what each variable does.
Tue May 23 2023 06:37:56 GMT+0000 (Coordinated Universal Time)
Saved by
@sharkies324
##c++
#include <iostream>
using namespace std;
int main() {
int x = 5;
int y = 6;
int sum = x + y;
// Integers (whole number)
int age = 21;
int year = 2023;
int days = 7;
int hours = 4.5; //this is able becuase int only contains whole number. The outpute would be 4 not 4.5
// double (number including decimal)
double price = 10.98;
double gpa = 2.5;
double temperature = 25.1;
// char (single character)
char grade = 'A';
char intitals = 'B';
char currency = '$';
// booleen (True or false)
bool student = false;
bool power = true;
bool forSale = true;
// stirng (objects that represents a sequence of text)
std::string name = "bro";
std::string day = "Friday";
std::string food = "Pizza";
std::string adress = "123 fake st.";
cout << "Hello " << name;
cout << "You are " << age << " years old";
return 0;
}
content_copyCOPY
Works well but this is my first time so I don't know yet.
https://www.programiz.com/cpp-programming/online-compiler/
Comments