Answer to Question #185509 in C++ for Woyengimiesindo

Question #185509

Write a function that reads real (fractional) numbers, 𝑥1, 𝑥2, … , 𝑥𝑁 from the keyboard 

into an array of N, starting from index 0. The numbers are read after a prompt.



1
Expert's answer
2021-04-30T23:13:46-0400
#include <iostream>


using namespace std;


int main()
{
    int n;
    cout<<"Enter the number  of data to be entered: ";
    cin>>n;
    float data[n];
    for (int i=0;i<n;i++){
        cout<<"Enter data number "<<i+1<<": ";
        cin>>data[i];
    }
    
    //display the entered data
    cout<<"Entered data:"<<endl;
    
    for (int i=0;i<n;i++){
        printf("%.2f", data[i]);
        cout<<"\t";
    }
    


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS