الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

جاوبولي تكفون

مغلق
بدأه sad angle في 9 ديسمبر 2011 · 7 رد · 472 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

الله يوفق كل من يرد علي ويفتح عليه

الكود ذا اذا سويتله كومبير ما يطلع عندي اخطاء بس عند التشغيل واخترت شكل من الموجود يطلع الجمله الاخيره من الس اش السبب يعني مثلا اخترت السيليندر ونفس الاسبلنغ بس يطلع

" تتوقعون اش السبب الله يوفقكم

The program does not handle

#include<iostream.h>
#include<iomanip.h>
#include<cmath>
const double PI=3.1416;
int main()
{
double height,width,length,radius;
char shape [33] ;
cout<<"Enter the shape type: (rectangle,circle,cylinder)";
cin>>shape;
cout<<endl;
if(shape=="rectangle")
{
cout<<"Enter the width of the rectangle ";
cin>>width;
cout<<endl;
cout<<"Enter the length of the rectangle ";
cin>>length;
cout<<"Perimeter of the rectangle = "<<2*(length+width)<<endl;
cout<<"Area of the rectangle = "<<length*width<<endl;
}
else
 if (shape== "circle" )
{
cout<<"Enter the radius of circal "<<endl;
cin>>radius;
cout<<"Area of the citcal = "<<PI*pow(radius,2.0)<<endl;
cout<<setprecision(2);
cout<<"Circumference of the circle:"<<2*PI*pow(radius,2.0)<<endl;
}
else
 if(shape=="cylinder")
{
cout<<"Enter the radius of cylinder "<<endl;
cin>>radius;
cout<<"Enter the height of the culinder ";
cin>>height;
cout<<"Volime of the cylinder : "<<PI*pow(radius,2.0)*height<<endl;
cout<<"Surface area of the cylinder : "<<2*radius+2*PI*pow(radius,2.0)<<endl;
}
else
cout<<"The program does not handle "<<shape<<endl;
return 0;
}
#2
#include<iostream.h>
int main()
{
int namber;
char A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
cout<<"Enter the integer number betwen 0 to 35 "<<endl;
cin>>namber;
if(namber<=9)
cout<<namber<<endl;
if(namber>=10)
cout<<static_cast<char>(namber)<<endl;
return 0;
}

وهذا الكود اش مشكلته انا ابغاه اذا دخل المستخدم اعداد اقل من اويساوي 9 يطبع العدد واذا اكثر يطبع بدل الرقم حرف يعني اذا دخل 10 يطبعA وهكذا اش مشكلتي هون تكفون جاوبو

#3
#include<iostream.h>
int main()
{
int number1,number2,number3;
cout<<"Enter three Numbers : "<<endl;
cin>>number1>>number2>>number3;
cout<<endl;
if (number1<number2) 
if (number1<number3)
cout<<number1;
else
if(number2>number3)
cout<<number3;
else
cout<<number2;
if(number2<number1)
if(number2<number3)
cout<<number2;
else
cout<<number3<<number2;
return 0;
}

ابغاه يطلع الارقام تصاعدي بس ما يزبط

#4

السلام عليكم ...

انا سأساعدك بأول كود .. و ثاني كود :

  1. طالما انك عرفت shape من نوع char [33] arry of size 33 إذا استخدم strcmp للمقارنة و الكود :
    #include<iostream>
    #include<iomanip>
    #include<cmath>
    #include <string.h>
    
    using namespace std;
    const double PI = 3.1416;
    
    int main() {
    	double height, width, length, radius;
    	char shape [33];
    	cout << "Enter the shape type: (rectangle,circle,cylinder)";
    	cin >> shape;
    	cout << endl;
    	if (strcmp(shape , "rectangle") == 0) {
        	cout << "Enter the width of the rectangle ";
        	cin >> width;
        	cout << endl;
        	cout << "Enter the length of the rectangle ";
        	cin >> length;
        	cout << "Perimeter of the rectangle = " << 2 * (length + width) << endl;
        	cout << "Area of the rectangle = " << length * width << endl;
    	} else
        	if (strcmp(shape , "circle") == 0) {
        	cout << "Enter the radius of circal " << endl;
        	cin >> radius;
        	cout << "Area of the citcal = " << PI * pow(radius, 2.0) << endl;
        	cout << setprecision(2);
        	cout << "Circumference of the circle:" << 2 * PI * pow(radius, 2.0) << endl;
    	} else
        	if (strcmp(shape  , "cylinder") ==0) {
        	cout << "Enter the radius of cylinder " << endl;
        	cin >> radius;
        	cout << "Enter the height of the culinder ";
        	cin >> height;
        	cout << "Volime of the cylinder : " << PI * pow(radius, 2.0) * height << endl;
        	cout << "Surface area of the cylinder : " << 2 * radius + 2 * PI * pow(radius, 2.0) << endl;
    	} else
        	cout << "The program does not handle " << shape << endl;
    	return 0;
    }

  2. ثاني كود : الحرف a يمثله الرقم 97 لذلك لو أردنا تحويل الــ 10 إلى a فقط نضيف إليها 87 و يصبح الكود :
    cout << static_cast<char> (namber+ 87) << endl;

    طبعا مع تعديل الكود كما في الكود السابق

    #include<iostream>
    using namespace std;

تم تعديل هذه المشاركة بواسطة houssam11350_11350 في 9 ديسمبر 2011 في 16:56

لا إله إلا الله ... محمد رسول الله

لو كانت مشاركتي مفيدة و تريد تشجيعي على المزيد من العطاء , فضلا قم بتقييم المشاركة

المعرًف القديم : houssam11350_11350

من مواضيعي : ArabGenCode : مولد كود و إجراءات مخزنة و واجهات لجداول سيكوال سيرفر

#5

وهذا حل للكود الثاللث على نفس خط محاولتك. لكن اذا ارت الترتيب بشكل فلابد من وضعها فى شكل مصفوفة ...الخ.

#include <iostream>
using namespace std;
int main()
{
    int number1,number2,number3;
    int temp = 0;
    cout<<"Enter three Numbers : "<<endl;
    cin>>number1>>number2>>number3;

    cout<<endl;
    temp = number1;

    if (number1 > number2)
    {
        temp = number2;
        number2 = number1;
        number1 = temp;
    }

    if (number1 > number3)
    {
        temp = number3;
        number3 = number1;
        number1 = temp;
    }

    if (number2 > number3)
    {
        temp = number3;
        number3 = number2;
        number2 = temp;
    }

    cout << number1<<"  " << number2 << " "<< number3 ;

    return 0;
}

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

#6

الله يعطيك الف عافيه يارب

بس انا اخذت تشار موعشان ابغى اسوي اراي

لا انا اخذتها لان اذا اخذت سترانغ يطلع ارور حتى واناكاتبه الهيدر فايل تبعها

مشكور

الف شكر محمد ابوزايد الله يعطيك الف عافيه

#7

السلام عليكم و رحمة الله و بركاته

هذه مساعدتي للسؤال الاول باستخدام ال string بدلا من ال char

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
const double PI=3.1416;
int main()
{
double height,width,length,radius;
string shape  ;
cout << "Enter the shape type: (rectangle,circle,cylinder)";
cin>>shape;
cout<<endl;
if(shape=="rectangle")
{
cout<<"Enter the width of the rectangle ";
cin>>width;
cout<<endl;
cout<<"Enter the length of the rectangle ";
cin>>length;
cout<<"Perimeter of the rectangle = "<<2*(length+width)<<endl;
cout<<"Area of the rectangle = "<<length*width<<endl;
}
else
 if (shape== "circle" )
{
cout<<"Enter the radius of circal "<<endl;
cin>>radius;
cout<<"Area of the citcal = "<<PI*pow(radius,2.0)<<endl;
cout<< setprecision(2);
cout<<"Circumference of the circle:"<<2*PI*pow(radius,2.0)<<endl;
}
else
 if(shape=="cylinder")
{
cout<<"Enter the radius of cylinder "<<endl;
cin>>radius;
cout<<"Enter the height of the culinder ";
cin>>height;
cout<<"Volime of the cylinder : "<<PI*pow(radius,2.0)*height<<endl;
cout<<"Surface area of the cylinder : "<<2*radius+2*PI*pow(radius,2.0)<<endl;
}
else
cout<<"The program does not handle "<<shape<<endl;
return 0;
}

تم تعديل هذه المشاركة بواسطة kaki في 10 ديسمبر 2011 في 12:14

#8

مشكور اخوي الف شكر

الله يعطي من ساعدني الصحه ويفتح عليه

مشكورين جميعا

هذا الموضوع مغلق.

مواضيع مشابهة