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

مسائل

مغلق
بدأه طالب برمجة في 30 ديسمبر 2003 · 3 رد · 880 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

عندي مجموعه تدريبات ياريت حد يعطيني الحل .......

Write a switch statement that does the following:

• Increases balance by adding amount to it if the value of the character variable transCode is 'D'.

• Decreases balance by subtracting amount from it if the value of transCode is 'W'.

• Display the value of balance if the value of transCode is 'P'.

• Display "Illegal transaction" otherwise.

#2

1. Write a function

void floattopp(float q, int& L, int& P)

which converts the sum of money q in Dirhams into L Dirhams and P Felses where the pence are correctly rounded. Thus if q was 24.5678 then L should be set to 24 and P should be set to 57.

Write a simple driver program to test the function. Think carefully about the boundary conditions.

2. Write a program to print the following shape on the screen. Use a for loop :

*

* *

* * *

* * * *

3. Write a C++ program to implement the following requirement:

A set of examination marks expressed as percentages are to be processed by computer. Data entry is terminated by entering a negative percentage value. As each examination mark is entered it should be validated as being either a valid percentage or as being a negative number. The program should ask for the data entry to be repeated until a valid value is entered. The program should then output the number of percentage marks entered, the average mark and how many marks were above 40

The program should implement the loop by using a do-while loop.

4. Consider the following nested switch statement

int x, y;

switch (x)

{

case 2 :

case 4 :

case 6 : switch (y)

{

case 1:

case 2:

case 3: x = x + y; break;

case -1:

case -2:

case -3: x = x - y; break;

}

break;

case 1 :

case 3:

case 5 : switch (y)

{

case 2:

case 4:

case 6: x = x * y; break;

case -1:

case -4:

case -6: x = y * y; break;

}

break;

}

cout << "x = " << x << endl;

cout << "y = " << y << endl;

What will be displayed by the code for each of the following values of LetterGrade?

1. x = 4; y = -2;

2. x = 3; y = 6;

3. x = 1; y = -4;

4. x = 7; y = -2;

5. x = 2; y = 5;

5. Write a switch statement that does the following:

• Increases balance by adding amount to it if the value of the character variable transCode is 'D'.

• Decreases balance by subtracting amount from it if the value of transCode is 'W'.

• Display the value of balance if the value of transCode is 'P'.

• Display "Illegal transaction" otherwise.

6. Write a program that does the following:

The program manipulate data concerning the number of hours of a group of 6 employees have worked in a particular week. This program should ask the user to enter hours number for each employee, store it into an array and finally display it on the screen.

A typical run might produce the following input/output:

Enter hours for employee number 1: 38

Enter hours for employee number 2: 42

Enter hours for employee number 3: 29

Enter hours for employee number 4: 35

Enter hours for employee number 5: 38

Enter hours for employee number 6: 37

in which case our block of variables would then be in the state:

#3

مسألة رقم 2 حلها هذا...

#include<iostream>

using namespace std;

int main()

{

for ( int q = 0; q < 4 ; q++)

{

for ( int z= 0; z<=(4-q); z++)

{

cout<<" ";

}

for ( int x= 0; x<(q*2)+1 ; x++)

{

cout<<"*";

}

cout << endl;

}

return 0;

}

#4

اهلين اخوي ,,

هذا سؤالك الاول ...

int balance;

char transCode;

cout << "Please enter character : ";

cin >> transCode;

switch( transCode )

{

case 'D' :

balance++;

break;

case 'W' :

balance--;

break;

case 'P' :

cout << "the value of balance : " << balance;

break;

default :

cout << "Illegal transaction.";

}

هذي طريقة الحل بشكل سريع

لكن زيادة الراتب والنقصان منه ما ادري هي صحيحه او لا

اخوك ابو سعود

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

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