Mohammed_13
Well-Known Member
- تاريخ التسجيل
- 5 مارس 2014
- المشاركات
- 1,031
- المجموعة
- ذكر
- الدفعة الدراسية
- 2013
- الكلية
- كلية تقنية المعلومات
- التخصص
- Computer Science
ترى التست عقب باجر :mellow: ، إذا في احد عطوهم اسئلة او شي ياليت يحطه هني جان نستفيد 


[/B][/LEFT]
[LIST=1]
[*]Write a value-returning function, [B]isVowel[/B] that returns the value [B]true[/B] if its character parameter is vowel and otherwise returns [B]false[/B].
[/LIST]
[B][U]Hint[/U][/B]: the vowels are: a, e, i, o, u.
[LIST=1]
[*]Write a program that prompts the user to input a sequence of characters and outputs the number of vowels. Use the function isVowel written in question 1.
[*]
[/LIST]
[LEFT][B]
[B]Q3[/B]
[CODE]Write a program that uses while loops to perform the following steps:
- Prompt the user to input two integers [B]first[/B] and [B]second[/B] (first < second).
- Output all odd numbers between first and second.
- Output the sum of all even numbers between first and second.
- Output the sum of the square of the odd numbers between first and second.
Write a program that reads a student’s name together with his or her test scores. The program should then compute the average test score for each student and assign the appropriate grade. The grade scale is as follows:
90-100, A 80-89, B 70-79, C 60-69, D 0-59, F
Your program must use the following functions:
[B]a. [/B]A void function, [B][U]calculateAverage[/U][/B], to determine the average of the five test scores for each student. Use a loop to read and sum the five test scores. (This function does not output the average test score. That task must be done in the function main.)
[B]b. [/B]A value-returning function, [B][U]calculateGrade[/U][/B], to determine and return each student’s grade. (This function does not output the grade. That task must be done in the function main.)
Test your program on the data saved in [B]data.txt[/B] (provided with the lab assignment in blackboard). Send the output to a file. Do not use any global variables. Use the appropriate parameters to pass values in and out of functions.
[B][U]Sample output[/U][/B]:
Student Test1 Test2 Test3 Test4 Test5 Average Grade
Ali 85 83 77 91 76 82.4 B
Zainab 86 90 95 93 88 90.4 A
Aysha 78 81 11 90 73 66.6 D
Mohamed 92 83 30 69 87 72.2 C
Reem 23 45 96 38 59 52.2 F
Q1
Write the program that displays the following grad of number using nested loops . Your output should be as folllows
56789
45678
34567
23456
12345
Q2
كود:[LIST=1] [*]Write a value-returning function, [B]isVowel[/B] that returns the value [B]true[/B] if its character parameter is vowel and otherwise returns [B]false[/B]. [/LIST] [B][U]Hint[/U][/B]: the vowels are: a, e, i, o, u. [LIST=1] [*]Write a program that prompts the user to input a sequence of characters and outputs the number of vowels. Use the function isVowel written in question 1. [/LIST]كود:[B]Q3[/B] [CODE]Write a program that uses while loops to perform the following steps: - Prompt the user to input two integers [B]first[/B] and [B]second[/B] (first < second). - Output all odd numbers between first and second. - Output the sum of all even numbers between first and second. - Output the sum of the square of the odd numbers between first and second.Q4
كود:Write a program that reads a student’s name together with his or her test scores. The program should then compute the average test score for each student and assign the appropriate grade. The grade scale is as follows: 90-100, A 80-89, B 70-79, C 60-69, D 0-59, F Your program must use the following functions: [B]a. [/B]A void function, [B][U]calculateAverage[/U][/B], to determine the average of the five test scores for each student. Use a loop to read and sum the five test scores. (This function does not output the average test score. That task must be done in the function main.) [B]b. [/B]A value-returning function, [B][U]calculateGrade[/U][/B], to determine and return each student’s grade. (This function does not output the grade. That task must be done in the function main.) Test your program on the data saved in [B]data.txt[/B] (provided with the lab assignment in blackboard). Send the output to a file. Do not use any global variables. Use the appropriate parameters to pass values in and out of functions. [B][U]Sample output[/U][/B]: Student Test1 Test2 Test3 Test4 Test5 Average Grade Ali 85 83 77 91 76 82.4 B Zainab 86 90 95 93 88 90.4 A Aysha 78 81 11 90 73 66.6 D Mohamed 92 83 30 69 87 72.2 C Reem 23 45 96 38 59 52.2 Fبإنتظار إجابتكم
![]()
@Mohammed_13
#include <iostream>
using namespace std;
int main()
{
int t=10;
for(int c=5;c>=1;c--){
for(int j=c;j<t;j++)
cout<<j;
cout<<endl;
t--;
}
system("pause");
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int x,y,sum=0,oddsum=0;
cout<<"Enter two integer number:";
cin>>x>>y;
while(x<y){
if(x%2==0)
sum+=x;
else oddsum+=x,cout<<x<<endl;
x++;
}
cout<<"Sum of even number:"<<sum<<endl;
cout<<"Sum of odd number:"<<oddsum*oddsum<<endl;
system("pause");
return 0;
}

#include<iostream>
using namespace std;
int main()
{
long i;
int cr;
float g;
int eg=0;
cout<<"enter students iD , GPA and hours ,negative to stop"<<endl;
cin>>i;
while (i!=-1)
{
if (g>=2 && cr>=95)
eg++;
cin>>i>>g>>cr;
}
cout<<"expected to graduate"<<eg<<"students"<<endl;
system("pause");
return 0;
}
السلام عليكمPHP:#include<iostream> using namespace std; int main() { long i; int cr; float g; int eg=0; cout<<"enter students iD , GPA and hours ,negative to stop"<<endl; cin>>i; while (i!=-1) { if (g>=2 && cr>=95) eg++; cin>>i>>g>>cr; } cout<<"expected to graduate"<<eg<<"students"<<endl; system("pause"); return 0; }
المفروض ان لما ندخل -1 يخلص البرنامج
بس على حسب حلي ان لازم ندخل -1 ثلاث مرات عشان يخلص البرنامج ليش !
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
float gpa,p;
int s=0;
int x=0;
cout<<"enter student GPA's"<<endl;
cin>>gpa;
while (gpa!=-1)
{
s++;
if (gpa==4) x++;
cin>>gpa;
}
p=x/s;
cout<<"there are"<<x<<"students with gpa of 4.0 \n";
cout<<fixed<<showpoint<<setprecision(2);
cout<<"they represent"<<p*100<<"of the students \n";
system("pause");
return 0;
}
PHP:#include<iostream> using namespace std; int main() { long i; int cr; float g; int eg=0; cout<<"enter students iD , GPA and hours ,negative to stop"<<endl; cin>>i; while (i!=-1) { if (g>=2 && cr>=95) eg++; cin>>i>>g>>cr; } cout<<"expected to graduate"<<eg<<"students"<<endl; system("pause"); return 0; }
المفروض ان لما ندخل -1 يخلص البرنامج
بس على حسب حلي ان لازم ندخل -1 ثلاث مرات عشان يخلص البرنامج ليش !
[SIZE=2][FONT=tahoma] cin>>i>>g>>cr;[/FONT][/SIZE]
[SIZE=2][FONT=tahoma] cin>>i;
while (i!=-1)
{
cout<<"Enter GPA and hours:";
cin>>g>>cr;
if (g>=2 && cr>=95)
eg++;
cout<<endl<<"Enter students ID,negative to stop:";
cin>>i;
}[/FONT][/SIZE]
الخطأ بسيط جداً المتغيرين x و s انتيجر فمهما كان ناتج القسمة مالهم بكون كله 0 ما عدا في حالة ان كل الطلبة معدلهم 4 بيطلع 1 و بيصير الجواب 100 % فقط غيري نوع المتغيير من انتجر الى فلوت و بتنحل المشكلةpercent of students with GPA of 4 يطلع 0 وين الخطأ :| ؟PHP:#include<iostream> #include<iomanip> using namespace std; int main() { float gpa,p; int s=0; int x=0; cout<<"enter student GPA's"<<endl; cin>>gpa; while (gpa!=-1) { s++; if (gpa==4) x++; cin>>gpa; } p=x/s; cout<<"there are"<<x<<"students with gpa of 4.0 \n"; cout<<fixed<<showpoint<<setprecision(2); cout<<"they represent"<<p*100<<"of the students \n"; system("pause"); return 0; }
، كان المطلوب حساب عدد الاحرف في ملف...#include <Iostream>
#include <fstream>
using namespace std;
int main()
{
int sum=0;
char ch;
ifstream infile;
infile.open ("file.txt");
if (!infile)
{
cout<<"cannot open file";
return 1;
}
infile>>ch;
while(!infile.eof())
{
sum++;
infile>>ch;
}
cout<<"sum="<<sum<<endl;
system ("pause");
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int num1,num2;
int x=num1,c1=0;
cout<<"enter first number:";
cin>>num1;
cout<<endl;
cout<<"enter second number:";
cin>>num2;
cout<<endl;
while(num1>num2)
{
cout<<"invalid"<<endl;
cout<<"enter first number:";
cin>>num1;
cout<<endl;
cout<<"enter second number:";
cin>>num2;
cout<<endl;
}
cout<<"the numbers divisible by 5 are:"<<endl;
while(x>=num1 && x<=num2)
{
if(x%5==0) c1++;
if(x%5==0)cout<<x<<endl;
x++;
}
cout<<"ther are"<<c1<<"numbers divisible by 5"<<endl;
system("pause");
return 0;
}
الغلط في اللوب الثاني لان مو قاعد يحسب شي اساساً ، الافضل انش تخلينه يحسب الارقام الي تنقسم على خمسة خلال اللوب الاولي تفضلي هذا الحلPHP:#include<iostream> using namespace std; int main() { int num1,num2; int x=num1,c1=0; cout<<"enter first number:"; cin>>num1; cout<<endl; cout<<"enter second number:"; cin>>num2; cout<<endl; while(num1>num2) { cout<<"invalid"<<endl; cout<<"enter first number:"; cin>>num1; cout<<endl; cout<<"enter second number:"; cin>>num2; cout<<endl; } cout<<"the numbers divisible by 5 are:"<<endl; while(x>=num1 && x<=num2) { if(x%5==0) c1++; if(x%5==0)cout<<x<<endl; x++; } cout<<"ther are"<<c1<<"numbers divisible by 5"<<endl; system("pause"); return 0; }
الجزء الثاني من البروقرام ما يشتغل صح
الا هو الاعداد الي تقبل القسمة على خمسة
وكم عددها .
لما اشغله يطلع 0 .
وين الغلط :| ؟
#include<iostream>using namespace std;
int main()
{
int num1,num2;
int x=num1,c1=0;
cout<<"enter first number:";
cin>>num1;
cout<<endl;
cout<<"enter second number:";
cin>>num2;
cout<<endl;
while(num1>num2)
{
cout<<"enter first number:";
cin>>num1;
cout<<endl;
cout<<"enter second number:";
cin>>num2;
cout<<endl;
if ( num1%5 == 0 )
{ c1++ ; }
if ( num2%5 == 0 )
{ c1++ ; }
}
cout<<"the numbers divisible by 5 are:" ;
cout << c1 << endl ;
system("pause");
return 0 ;
}
جربته بعد يطلع 0 !الغلط في اللوب الثاني لان مو قاعد يحسب شي اساساً ، الافضل انش تخلينه يحسب الارقام الي تنقسم على خمسة خلال اللوب الاولي تفضلي هذا الحل
كود:#include<iostream>using namespace std; int main() { int num1,num2; int x=num1,c1=0; cout<<"enter first number:"; cin>>num1; cout<<endl; cout<<"enter second number:"; cin>>num2; cout<<endl; while(num1>num2) { cout<<"enter first number:"; cin>>num1; cout<<endl; cout<<"enter second number:"; cin>>num2; cout<<endl; if ( num1%5 == 0 ) { c1++ ; } if ( num2%5 == 0 ) { c1++ ; } } cout<<"the numbers divisible by 5 are:" ; cout << c1 << endl ; system("pause"); return 0 ; }
اختي اتوقع ولا رقم دخلتيه ينقسم على الرقم 5 فشي طبيعي انه بيطلع صفرجربته بعد يطلع 0 !
الارقام الي دخلتها num1=1 & num2=10اختي اتوقع ولا رقم دخلتيه ينقسم على الرقم 5 فشي طبيعي انه بيطلع صفر
شوفي هاذي الصورة كوبايل لنفس الكود و دخلت رقمين ينقسمون على 5 الي هم 20 و 10 في النهاية طلع لي الارقام الي تنقسم على 5 هي 2
https://drive.google.com/file/d/0By6IydPqj2WAZWdocXJiSzRJOHc/view?usp=sharing
الارقام الي دخلتها num1=1 & num2=10
السؤال كان طالب ان ندخل num1 &num2 بحيث ان يكون num1 less than num2
وبعدين يطلع الارقام الي تقبل على خمسة ما بين الرقمين.
فالمفروض يطلع 5 و 10 صح ؟
while (num1<=num2)
{
if(num1%5==0)
{
c1++;
cout<<num1<<endl;
}
num1++;
}
cout<<"ther are "<<c1<<" numbers divisible by 5"<<endl;
لا أختي بيطلع بس رقم واحد يقبل القسمة على 5 الي هو 10 لانش دخلتين رقمين بس الي هم 10 و 1 و ال 10 بس ينقسم على 5الارقام الي دخلتها num1=1 & num2=10
السؤال كان طالب ان ندخل num1 &num2 بحيث ان يكون num1 less than num2
وبعدين يطلع الارقام الي تقبل على خمسة ما بين الرقمين.
فالمفروض يطلع 5 و 10 صح ؟
لا أختي بيطلع بس رقم واحد يقبل القسمة على 5 الي هو 10 لانش دخلتين رقمين بس الي هم 10 و 1 و ال 10 بس ينقسم على 5
بالنسبة للسؤال يبغي تسوين سي اوت للارقام التنقسم على 5 أو يبغي يحسبهم ؟ أو الاثنين ؟
سي اوت حق الارقام الي تنقسم على 5 ما بين num1 و num 2 ويحسبهملا أختي بيطلع بس رقم واحد يقبل القسمة على 5 الي هو 10 لانش دخلتين رقمين بس الي هم 10 و 1 و ال 10 بس ينقسم على 5
بالنسبة للسؤال يبغي تسوين سي اوت للارقام التنقسم على 5 أو يبغي يحسبهم ؟ أو الاثنين ؟
حطي هذي الجزئية وبيشتغل اوكي
كود:while (num1<=num2) { if(num1%5==0) { c1++; cout<<num1<<endl; } num1++; } cout<<"there are "<<c1<<" numbers divisible by 5"<<endl;

الجزء الثاني من البروقرام ما يشتغل صحكود:#include<iostream> using namespace std; int main() { int num1,num2; int [B][SIZE=4][COLOR=#ff0000]x=num1[/COLOR][/SIZE][/B],c1=0; cout<<"enter first number:"; cin>>num1; cout<<endl; cout<<"enter second number:"; cin>>num2; cout<<endl; while(num1>num2) { cout<<"invalid"<<endl; cout<<"enter first number:"; cin>>num1; cout<<endl; cout<<"enter second number:"; cin>>num2; cout<<endl; } [B][SIZE=4][COLOR=#ff0000]x=num1;[/COLOR][/SIZE][/B] cout<<"the numbers divisible by 5 are:"<<endl; while(x>=num1 && x<=num2) { if(x%5==0) c1++; if(x%5==0)cout<<x<<endl; x++; } cout<<"ther are"<<c1<<"numbers divisible by 5"<<endl; system("pause"); return 0; }
الا هو الاعداد الي تقبل القسمة على خمسة
وكم عددها .
لما اشغله يطلع 0 .
وين الغلط :| ؟
