Smart
Well-Known Member
- تاريخ التسجيل
- 9 سبتمبر 2012
- المشاركات
- 98
- المجموعة
- أنثى
- الدفعة الدراسية
- 2012
- الكلية
- كلية العلوم
شكرا جزيلا

شكرا جزيلا \ ماكنت اقصد يطلع جي بس نفس الفكرة فعرفت للسؤال



سلام عليكم .. عندي اسايمنت ... واخر وقت تسليمه ساعه 12 ... ماعلينا
بغيت بس الفكرة ... ولا شنو استخدم له
السؤال يقول :
Write a C++ program to sum and number all even integers that are divisible by 6 in the range (X,Y). Integers X and Y are to be input by the user. Your program should check that X is smaller than Y and output error message if not.
Sample input/output
Enter the value of x an y : 20 10
Error message x should be smaller than y
Enter the value of x an y : 1 30
Number of even integers divisible by 6= 5
Sum of even integers divisible by 6 = 90
حليته ف البداية صح .. طلعت error بس اللي بعده ما اعرف شلون احله .. او شنو الطريقة .. بس بغيت الشرح والطريقة اذا ما عليكم امرر
وشكرا مقدما![]()
while(x>y)
if(i%6==0 && i%2==0)
sum+=i;
count++;

سلام عليكم ... عندي اسايمنت اقدمه ساعه 12 اخر وقت للتسليم .. ماعلينا
السؤال يقول :
Write a C++ program to sum and number all even integers that are divisible by 6 in the range (X,Y). Integers X and Y are to be input by the user. Your program should check that X is smaller than Y and output error message if not.
Sample input/output
Enter the value of x an y : 20 10
Error message x should be smaller than y
Enter the value of x an y : 1 30
Number of even integers divisible by 6= 5
Sum of even integers divisible by 6 = 90
انا حليته بس البداية صح .. وبعدين لا بغيت بس شررح او فكرة الحل .. error سويته .. بس الثاني ما يستوي
شنو لازم استخدم له ؟؟
ومشكورين مقدما ..
اوووه عجل انتين من قائمتنا اللي كنا معلقين في اللاب اليوم
اني حليته في اللاب و حليته في البيت و بعد عندي خلل بسيط للحين ماضبط اذا ضبط بفهمش جيفه حليته
و التسليم ميس اللاب قالت السبت ساعه ظ،ظ،:ظ¥ظ©pm مو الليله
int count = 0;
int sum = 0;
for ( int i=x ; i<=y ; ++)
for (int i = x ; i<=y ; i++)
{
if ( i%2 ==0 )
{
if ( i%6==0 )
{
sum = sum+i;
count++;
}
}
}

بالنسبة حق النقطة الثانية
اول شي تعرفون 2 فاريبل
HTML:int count = 0; int sum = 0;
ثاني شي تسوون فور لوب يبتدي من x و ينتهي عند y
HTML:for ( int i=x ; i<=y ; ++)
داخل الفورلوب
اول خطوة تتاكدون من الرقم هل هو زوجي او لا
ثاني خطوة اذا كان العدد الزوجي هل يقبل القسمة على 6 او لا
اذا يقبل القسمة على 6 تضيفون هالرقم على sum و تزيدون العدد count 1
يعني 2 اف ستيتمنت داخل بعض
HTML:for (int i = x ; i<=y ; i++) { if ( i%2 ==0 ) { if ( i%6==0 ) { sum = sum+i; count++; } } }
اذا في شي مب واضح حطو اسألتكم ... لاني مستعيل ماشرحته عدل
بالتوفيق

عشان يطلع من اللوب لما يكون الرقم الاول اصغر من الثانيمثل حلي بس يطلع خلل لما ادخل ايرور انبت وبعدين ارد ادخل انبوت صح السم و النم يطلعون ظ* في طريقي لحل هذا الخلل

do {
....
..}while(x>y);



من يعرف لهالحل
(1)
1
12
123
1234
12345
(2)
1
21
321
4321
54321
(3)
5 6 7 8 9
4 5 6 7 8
3 4 5 6 7
2 3 4 5 6
1 2 3 4 5


السلام عليكم عندي سؤال ابي له حل ضروري اليوم التسليم رحم الله والديكم ساعدووني في csc 103
Consider an input file named “numbers.txt” as shown below. Note that the file contains an unknown number of positive integers. Each number represents the triangle of stars (*). Write a C++ program that display and print in an output file named “outfile.txt” triangle of stars for each number in that file as shown below.
(numbers.txt )
3
5
2
(outfile.txt)
***
**
*
*****
****
***
**
*
**
*
ساعدوني رحم الله والديكم
ifstream inFile;
ofstream outFile;
inFile.open("numbers.txt");
outFile.open("outfile.txt");
int x ;
while (!infile.eof())
infile>>x;
while (!infile.eof()) {
infile>>x;
for (int i = x ; i>=0 ; i-- ) {
for ( int j = 0 ; j<i ; j++ ) {
outfile<<"*"; }
outfile<<endl;
}
outfile<<endl;
outfile<<endl;
}
outfile<<"*";
inFile.close();
outFile.close();
#include <iostream>
using namespace std;
int main(){
ifstream inFile;
ofstream outFile;
inFile.open("numbers.txt");
outFile.open("outfile.txt");
int x ;
while (!infile.eof()) {
infile>>x;
for (int i = x ; i>=0 ; i-- ) {
for ( int j = 0 ; j<i ; j++ ) {
outfile<<"*"; }
outfile<<endl;
}
outfile<<endl;
outfile<<endl; }
inFile.close();
outFile.close();
return 0;
}


include<iostream>[/LEFT]
using namespace std;
int value( int n , int i , int sum , int result ) {
for ( i = 0 ; n <= i ; --i ){
sum= n * i ;
}
result*=sum ;
}
return value ;
int main(){
int s ;
cout << " Enter the number : \n " ;
cin >> s ;
if ( n < 0 )
cout << " Error the virable is less than 0 \n " ;
cout << " The sum = " << sum(int result)<< endl ;
system("pause") ;
return 0 ;
}
[LEFT]
عندي سوال بالنسبة لاخر اسايمنت الي هو
(A) Write a function that takes a positive integer N as parameter. The function should calculate and print the value of SUM where
SUM = 1! + 2! + 3! + … + N!
( i.e. 5! = 5 * 4 * 3 * 2 * 1 )
Appropriate error message must be displayed if N is invalid.
(B) Write a program to use the above function.
انا شبه متأكد من البرنامج بس كلما أجي اشغله يطلع لي ايرور في المين فنكشن إلى عنده فكره في وين الخطأ يفيدني
HTML:include<iostream>using namespace std; int value( int n , int i , int sum , int result ) { for ( i = 0 ; n <= i ; --i ){ sum= n * i ;}result*=sum ;}return value ; int main(){ int s ; cout << " Enter the number : \n " ; cin >> s ; if ( n < 0 ) cout << " Error the virable is less than 0 \n " ; cout << " The sum = " << sum(int result)<< endl ; system("pause") ; return 0 ; }
int value( int n , int i , int sum , int result )
int value( int n )