مقدمة في البرمجة باستخدام لغة++C مقدمة في البرمجة باستخدام لغة++C

آخر الأخبار

جاري التحميل ...

update variables

 


Changing Variable Values

Note that if you assign a new value to an existing variable, it will overwrite the previous value:

Example

int myNum = 15;  // myNum is 15
myNum = 10;  // Now myNum is 10
cout << myNum;  // Outputs 10

Other Types

A demonstration of other data types:

Example

int myNum = 5;               // Integer (whole number without decimals)
double myFloatNum = 5.99;    // Floating point number (with decimals)
char myLetter = 'D';         // Character
string myText = "Hello";     // String (text)
bool myBoolean = true;       // Boolean (true or false)

Display Variables

The cout object is used together with the << operator to display variables.

To combine both text and a variable, separate them with the << operator:

Example

int myAge = 35;
cout << "I am " << myAge << " years old.";

You can also combine different types, which you will learn more about in a later chapter.

Example

string name = "John";
int age = 35;
double height = 6.1;

cout << name << " is " << age << " years old and " << height << " feet tall.";

Add Variables Together

To add a variable to another variable, you can use the + operator:

Example

int x = 5;
int y = 6;
int sum = x + y;
cout << sum;

watch this video
resources
https://www.w3schools.com/cpp/cpp_variables.asp

عن الكاتب

cpp

التعليقات


اتصل بنا

إذا أعجبك محتوى مدونتنا نتمنى البقاء على تواصل دائم ، فقط قم بإدخال بريدك الإلكتروني للإشتراك في بريد المدونة السريع ليصلك جديد المدونة أولاً بأول ، كما يمكنك إرسال رساله بالضغط على الزر المجاور ...

جميع الحقوق محفوظة

مقدمة في البرمجة باستخدام لغة++C