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

مساعده في برنامج ++C

بدأه لولو كاتي في 21 مايو 2011 · 2 رد · 380 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

انا عندي ماده مقدمه في البرمجه وطالبه الاستاذه واجب بالسويتش وكل كايس نستخدم فيه Loopانا عملت الكود وكتبته بس يطلع لي تحذير واذا عدلت التحذير طلع خطا فبليز ساعدوني لاني من جد تعبت منه

هذا كتابتي للكود

#include<iostream>

using namespace std;

void main()
{
	int n,i;
	int sum=0,fact=1,max=0;
	double d;

cout<<"1.summation of anumber\n";
cout<<"2.factorial of a number\n";
cout<<"3.the largest number between 5 numbers\n";
cout<<"4.convert ion from SR to $\n";
cout<<"5.exist\n";

switch (n)
{
case 1:
	cout<<"enter your number\n";
cin>>n;
    for (int i=1;i<=n;i++)

		sum+=i;
		cout<<"the summation is"<<sum;
	break;

case 2:
	cout<<"enter your number\n";
cin>>n;
	cout<<"the factorial";
	for ( int i=0;i<=n;i++)
	 fact*=i;
	cout<<fact;
break;

case 3:
	cout<<"enter your number\n";
cin>>n;
	for (int i=0;i<=5;i++)
			if (n>max)
				max=n;
	cout<<"the max is"<<max;

break;

case 4:
	cout<<"enter the amount riyal"<<endl;
	cin>>n;
	i=(n/3.75);
	cout<<"dollar"<<i; 
default:
cout<<"exist";
}
}

ساعدوني بليز احتاجه ضروري

#2

اول شي ابدائي اعطي n قيمة قبل ما تعملي لها case في الswitch

لازم الادخال لقيمة n قبل ما تستخدميها

عدلي الكود بهذا الشكل

#include<iostream>

using namespace std;

void main()
{
        int n,x;
        int sum=0,fact=1,max=0;
        double d;

cout<<"1.summation of anumber\n";
cout<<"2.factorial of a number\n";
cout<<"3.the largest number between 5 numbers\n";
cout<<"4.convert ion from SR to $\n";
cout<<"5.exist\n";
cin >> x;
switch (x)
{
case 1:
        cout<<"enter your number\n";
cin>>n;
    for (int i=1;i<=n;i++)

                sum+=i;
                cout<<"the summation is"<<sum;
        break;

case 2:
        cout<<"enter your number\n";
cin>>n;
        cout<<"the factorial";
        for ( int i=0;i<=n;i++)
		   fact*= (i == 0)?1:i;
        cout<<fact;
break;

case 3:
        cout<<"enter your number\n";
cin>>n;
        for (int i=0;i<=5;i++)
                        if (n>max)
                                max=n;
        cout<<"the max is"<<max;

break;

case 4:
        cout<<"enter the amount riyal"<<endl;
        cin>>n;
        d=(n/3.75);
        cout<<"dollar"<<d; 
default:
cout<<"exist";
}
}

تم تعديل هذه المشاركة بواسطة mental-driller في 21 مايو 2011 في 23:21

1

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#3

البرنامج زبط يعطيك الف عافيه ♥♥

تم تعديل هذه المشاركة بواسطة لولو كاتي في 23 مايو 2011 في 23:20

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