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

لو سمحتوا ممكن مساعده

مغلق
بدأه بـــدور في 5 نوفمبر 2003 · 5 رد · 811 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

لو سمحتوا بغيت حل لهذا السؤال:-

QUOTE]Write a C++ program that performs the following:

(a) Your program should generate two random numbers. The first number is between 0 and 99 and the

second number between 0 and 29. The C++ function rand() generates random numbers between 0

and RAND MAX (its default value is implementation defined, for example, RAND MAX in Microsoft

Visual C++ is 32767). Generate random numbers using srand with time as a seed.

(B) Once the two integers have been generated randomly; your program should call one function that adds the two numbers, another function that subtracts them, and a third function to multiply the sum and difference. The sequence of calls must be as follows:

main calls the sum function passing the two numbers as parameters.

sum invokes the subtract function by passing three parameters, the two numbers and sum, then

subtract calls the product function by passing two parameters, the sum and difference of the two integers.

sum and subtract should return a value of type integer. product should return a value of float type. Also, subtract should calculate the square root of the returned product.

Here is a sample of an input/output

The Maximum positive random that can be generated on Microsoft Visual C++ is: 32767

The first generated random number between 0 and 99 is: 80

The second generated random number between 0 and 29 is: 23

The sum is: 103

The diff is: 57

The prod is: 5871

Square root of the product is: 76.62

#2

السلام عليكم,

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

هاهو الكود هنا وفي الملف المرافق:

#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

int Sum(int,int);
int Diff(int,int);
float Mult(int,int);
void main()
{
	srand( (unsigned)time( NULL ) );
	int number1,number2;
	number1=rand()%100;
	number2=rand()%30;
	int s=Sum(number1,number2);
	int d=Diff(number1,number2);
	float prod=Mult(s,d);
	cout << "The first number is : " <<number1 <<"\n";
	cout << "The second number is : " << number2 << "\n";
	cout << "the Sum is : "<< s <<"\n";
	cout << "The Diff is : " << d<<"\n";
	cout <<"The product is : "<< prod << "\n";
	if(d >=0)
	{
  double square=sqrt(d);

  cout << "The squre rooot is : " << square << "\n";
	}
	else
	{
  cout <<"Can't calculate The Sqrt of negative numbers \n";
	}

}

int Sum(int x,int y)
{
	return x+y;
}
int Diff(int x,int y )
{
	return x-y;
}
float Mult(int x,int y)
{
	return (float)x*y;
}

مع متمبياتي لك بالتوفيق.

RanDom.cpp

#3

شكرًا جزيلاً chik

لوسمحتوا (والله مستحيه منكم) بدون كلافه عندي سؤالين ومحتاجه أعرف الجواب

Exercise 1

Given the following table of sin(θ), where θ is given in degrees

)the table is in the file)

Write a C++ program to print the above table in a file sin.out. Use the table to find the sin of, for example, 35 degrees, you would look for the row starting with 30, then move across to the column for 5, giving you a value of 0.574.

Note about sin: The prototype for the sin function is in the < cmath > header file. The argument of sin is given in radians, not degrees.

radians = degrees × Pi /180

where Pi is approximately 3.1415926.

Note: You may notice slight differences in the results between your program and the above table. This is not very significant.

Exercise 2

Write a program that performs the following functions:

• (a) Writes a function with the prototype:

bool isNegative(float)

that returns true if the given value is less than 0 and returns false if the given value is not less than 0.

• (B) Writes a function with the prototype:

float validSqrt(float)

that returns the sqrt of the given value if the value is not negative and returns -1.0 if the value is

negative. This function must use the function isNegative of part (a).

• © Your program should test the function validSqrt. The program should read values from a file

input.dat and output the square root or an error message as is appropriate in a file result.out

Example:

4

The square root of 4 is 2.

0

The square root of 0 is 0.

-3

The square root of -3 is not possible.

table.txt

تم تعديل هذه المشاركة بواسطة بـــدور في 7 نوفمبر 2003 في 01:17

#4

......

#5

هلا أختي ،،، بدور ،،

طيب لييه ما تعرضي لنا محاولتك ،،..؟؟

لازم يا عزيزتي تحاولي ،، و حنا راح نساعدك في حالة وجود error ،،

و اعتذر لتدخلي ،، :)

أختك ،، العصامية ،،

#6

مشكوره العصاميه على المداخله

أنا حاولت وحليت

ومشكورين على تعاونكم

:)

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

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