this is my code and result I just create a structure first and then set up a for loop to use that elements and take input from user and display at last of the code part. please help me
#include <iostream>
using namespace std;
struct person
{
char name[30];
int age;
int phone_no;
}p[5];
int main()
{
for (int i=0; i<5; ++i)
{
cout<<"Enter you details \n\n\n";
cout<<" Enter your name : ";
cin.get(p[i].name,30);
cout<<"\n Enter your age : ";
cin>>p[i].age;
cout<<"\n Enter your phone no : ";
cin>>p[i].phone_no;
}
for (int i=0; i<5; ++i)
{
cout<<"\n\n\n Person's name : "<<p[i].name<<"\n Age : "<<p[i].age<<"\n Phone no : "<<p[i].phone_no;
}
return 0;
}
result
Enter you details
Enter your name : Ram
Enter your age : 12
Enter your phone no : 9898874645
Enter you details
Enter your name :
Enter your age :
Enter your phone no : Enter you details
Enter your name :
Enter your age :
Enter your phone no : Enter you details
Enter your name :
Enter your age :
Enter your phone no : Enter you details
Enter your name :
Enter your age :
Enter your phone no :
Person's name : Ram
Age : 12
Phone no : 2147483647
Person's name :
Age : 0
Phone no : 0
Person's name :
Age : 0
Phone no : 0
Person's name :
Age : 0
Phone no : 0
Person's name :
Age : 0
Phone no : 0
Process exited after 12.16 seconds with return value 0
Press any key to continue . . .
I also want to u add some useful advice if you have regarding my code skill