السلام عليكم
هذا سؤال عن الــ Array
اول كود اسويه بالارري
عارفة انه غلط وانا كمان مافهمت السؤال زيين
بس سويت كود على السريييييييع
هذا السؤال
Write a C++ program that reads a sequence of characters ends with '$' that represents a
floating – point number.
Your program should divide this sequence into :
• A sign (+,-)
• The integer part ( the part before the DOT).
• The decimal part ( the part after the DOT).
For simplicity, assume that the user will not enter a non-valid characters ( letters,
spaces … ). For example if the user input is -12.45$ , your program should display :
• In main, define a character array of maximum size 256.
• Provide readArray(char arr[]) function that reads a sequence of characters
representing the floating point from the user until he/she enters '$' . ( Hint : use
getline function).
• Provide DivideFloat(char arr[]) function that prints the components of a
floating point number stored in arr.
وهذه المحاااولة
#include <iostream>
#include <iomanip>
using namespace std;
void readarray(char arr[])
{
double number;
cin.getline(number);
}
void dividfloat(char arr[])
{
readarray(arr[]);
cout<<showpos<<number;
cout<<" The Integer Part is : "<<static_cast<int>(number);
if(number<0)
cout<<" The Number is Negative ";
else
cout<<" The Number is Positive";
}
int main()
{
double arr[256];
dividfloat(arr[]);
return 0 ;
}
