Page 13 - مجلة طموح IT
P. 13
C++الدرس الثاني المتغيرات وانواعها
ولإيجاد ناتج جمعهما سيكونb=3 المتغيرa=4 هو جزء من الذاكرة يستخدم لحفظ قيمة معينه واستخدامها لاحقا في البرنامج مثلا لنفرض ان المتغير
7 النتيجةsum= a + b
كمتغيراتSpaces, punctuation marks, and symbols ممكن ان يكون المتغير حرف او سلسله ارقام وحروف من ضمنها (_ ) لايمكن استخدام
. a هو ليس نفسهA حساسة للأحرف فالمتغير++cيجب ملاحظة ان
: هناك بعض الكلمات تسمى المفتاحية او المحجوزة لايمكن للمبرمج ان يستخدمها في يرنامجه وهي
alignas, alignof, and, and_eq, asm, auto, bitand, bitor, bool, break, case, catch, char, char16_t, char32_t, class, compl, const,
constexpr, const_cast, continue, decltype, default, delete, do, double, dynamic_cast, else, enum, explicit, export, extern, false,
float, for, friend, goto, if, inline, int, long, mutable, namespace, new, noexcept, not, not_eq, nullptr, operator, or, or_eq,
private, protected, public, register, reinterpret_cast, return, short, signed, sizeof, static, static_assert, static_cast, struct, switch,
template, this, thread_local, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void, volatile, wchar_t,
while, xor, xor_eq
انواع المتغيرات الرئيسية
'$'اوA'تمثل حرف واحد مثل:Character types
يتم خزن الارقام بكل قيمها وهيه تختلف بأحجامها و تقسم الى:Numerical integer types
‘حجمه على الاغلب بايت واحد
حسب استخدامها لإشارة السالب ام لا:signed or unsigned
3.14 or 0.003 تمثل القيم الحقيقية مثل:Floating-point types
true or false لديها قيمتين فقط:Boolean type
المستخدمfloating-point وهذه الاعداد تختلف قيمها حسب الدقة اعتمادا على نوع
#include <iostream> :Constant
using namespace std; هي قيم ثابته على طول البرنامج اينما تذكر قيمته ستكون ثابته لا تتغير في المثال التالي سنستخدم قيم ثابتة
31.4159
const double pi = 3.14159;
const char newline = '\n';
int main () //
{
double r=5.0;
radius
double circle;
circle = 2 * pi * r;
cout << circle;
cout << newline;
}
اسيل سعد 13

