لتقوم بكتابة برمجة حساب مساحة المستطيل ,ستحتاج إلى ثلاث متغيرات , واحد لطول المستطيل l و الثاني لعرضه w و الثالث للمساحة area :;float area,l ,w ;"cout << "please enter the Length and width of the rectangle; cin>>l>>w ;area =l*w ;cout <<"the area of the rectangle is "<< area
اولا يجب ان نعرف قانون مساحه المستطيل = الطول X العرض فلذلك سنعرف متغير للطول ومتغير للعرض حيث يتم ادخال المتغيرات من قبل المستخدم ومتغير اخر لنخزن فيه قيمه المساحه.
;double A,B ;double rectanglearea ;"cout << "please enter the Length of the rectangle; cin>> A ;" cout << "please enter the width of the rectangle; cin>> B ; rectanglearea =A*B ;cout <<"the area of the rectangle is "<< rectanglearea