السلام عليكــم ورحمـة الله وبركاتــه ،،
هذا هو السؤال ..
Write a C++ program that reads a group of numbers from the user (maximum 50 integers) and places them in an array of type double. These numbers represent the lengths in inches. Once the numbers are stored in the array, your program should provide a function that converts the length in inches to centimeters then print them.
In main define :
- Array size as const variable with value of 50.
- An array numbers using the const variable.
- n variable use to save the numbers of element in an array. Make sure that n is a positive number <= 50.
- A pointer Ptr that points to the first element in the Array numbers.
Global functions:
- ReadArray (double* Nptr, int n): that reads n elements from the user.
- Centimize (double* ptrd, int n): that converts the length in inches to centimeters.
- PrintArray (const double *Nptr, int n): that prints n elements of an array.
وهذا الكود اللي سويته ..
#include <iostream>
using namespace std;
//==========================================
double ReadArray (double* Nptr, int n):
{
cout<<" How many numbers would you like to enter? \n";
cin >> n ;
while !=( n >=1 && n <=50){
cout<< " you Enter an Valide number .. Please Re Enter it again :";
cin >> n ;
}
return n ;
}
//==========================================
void Centimize (double* ptrd, int n)
{
* ptrd *= 2.54 ;
}
//==========================================
PrintArray (const double *Nptr, int n){
cout<< *Nptr ; }
//==========================================
int main(){
int Array size =50 ;
double a[Array size] ;
int *p ;
int n;
ReadArray (double* Nptr, int n) ;
Centimize (double* ptrd, int n);
PrintArray (const double *Nptr, int n) ;
return 0;
}
إيش الخطأ اللي عندي وياليت أحد يصححه لي ..