This program allows the user to input 5 floating-point numbers and then displays them. First, it declares an array a of 5 floating-point numbers. It then prompts the user to enter 5 numbers using the cin function and stores them in the array using pointers with the notation *(a+i). Finally, it displays the 5 numbers using a for loop and the cout function, accessing each element of the array using a pointer with the notation *(a+i).
#include<iostream> using namespace std; int main() { float a[5]; cout<<"Enter 5 numbers: "; for(int i=0;i<5;++i) { cin>>*(a+i); } cout<<"Displaying data: "<<endl; for(int i=0;i<5;++i) { cout<<*(a + i)<<endl ; } return 0; }To download raw file Click Here
Enter 5 numbers: 12.3 45.5 56.7 89.7 90.7 Displaying data: 12.3 45.5 56.7 89.7 90.7
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions