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
   8   9   10   11   12   13   14   15   16   17   18