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

أسئلة أكتب برنامج .. write program بليز ..

بدأه Last King في 12 أبريل 2011 · 4 رد · 4,056 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

أخواني الغالين عندي تقريبااا اربعة اسئلة .. ممكن احد يساعدني في حلهاااااا واكون شاكر لكم

---------------------------------------------------

Q1: Write a program that asks user to choose one of these shaps rectangle , right-angled triangle or square then print the selected one out of asterisks (*). knowing that you should read shape's dimension from user. Your output should be something like the following

Example:

Hello, Please choose one of the following shapes

1- Rectangle

input

2- Right-angled triangle

3- Square

Enter your choice: 1

Please enter rectangle width: 8

Please enter rectangle height: 3

* * * * * * * *

* * * * * * * *

* * * * * * * *

----------------------------------

Q2: Write a program for a grocery that reads products data and determine and display the product that has the highest price and the average price. A product has three pieces of data: id (int), name (String) and price (double).Your program should continue reading new products until user enters -1 as id of a product.

Example:

ID Name price

1001 Pepsi 1.5

1021 Kit Kat 2

1011 Chips 1

-1 -1 -1

-----

The most expensive product is:

Id: 1021

Name: Kit Kat

Price: 2 S.R.

Average price = 1.5

Q3: Write a program that reads a set of integers, and then finds and prints the sum of the even and odd integers.

input

Example:

How many numbers in your set of integers? : 6

2 4 3 6 7 1

Sum of odd numbers = 11

Sum of even numbers = 12

(Self study exercise)

Q4: The greatest common divisor (GCD) of two integers is the largest integer that evenly divides each of the two numbers. Write a program that reads two integers and then prints their greatest common divisor.

Example:

Enter first integer: 4

Enter second integer: 8

The greatest common divisor is 4

Hint :

To declare a variable of type string, you need to include the standard string class:

- In the header:

#include <string>

- In the declaration:

string varName

#2

Q3: Write a program that reads a set of integers, and then finds and prints the sum of the even and odd integers.

input

Example:

How many numbers in your set of integers? : 6

2 4 3 6 7 1

Sum of odd numbers = 11

Sum of even numbers = 12

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int k;

int h;

int x=0;

int y=0;

cout<<"how many numbers in your set of integer?";

cin>>k;

for (int i=1;i<=k;i++)

{

cin>>h;

if(h % 2==0)

x=x+h;

else

y=y+h;

}

cout<<"the sum of even is="<<x <<"\n";

cout<<"the sum of odd is ="<<y;

getch();

}

#3

الله يعطيك الف عافية ياغالي بانتظار حل المجموعة الاخرى

#4

Q1: Write a program that asks user to choose one of these shaps rectangle , right-angled triangle or square then print the selected one out of asterisks (*). knowing that you should read shape's dimension from user. Your output should be something like the following

Example:

Hello, Please choose one of the following shapes

1- Rectangle

input

2- Right-angled triangle

3- Square

Enter your choice: 1

Please enter rectangle width: 8

Please enter rectangle height: 3

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int a,b,c,i,j;

cout<<"hello,pleease chooseone of the following shapes"<<"\n";

cout<<"1-rectangle \n";

cout<<"2-righ-angled triangle\n";

cout<<"3-square \n enter choice";

cin>>a;

switch (a)

{

case 1:

{ cout<<"please enter rectangle whidth: ";

cin>>b;

cout<<"\npleaseenter rectangle height: ";

cin>>c;

for(i=0;i<c;i++)

{

for(j=0;j<b;j++)

cout<<"*";

cout<<"\n";

}

break;

}

//هناء تكتب case 2 and case 3

}

getch();

}

حاول تكمل الحالتين الباقيه

#5

ناصر الله يسعدك ويوفقك ياغالي ماقصرت معي لبى قلبك

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