Show person Information using Structure in C++


Example Program:

Here is the simple program for showing person Information using Structure in C++.

Source Code

#include<iostream>
using namespace std;
struct Person
{
  char name[50];
  int age;
  float salary;
};
int main()
{
  Person p1;
  cout<<"Enter Full name: ";
  cin.get(p1.name,50);
  cout<<"Enter age: ";
  cin>>p1.age;
  cout<<"Enter salary: ";
  cin>>p1.salary;
  cout<<"\nDisplaying Information."<<endl;
  cout<<"Name: "<<p1.name<<endl;
  cout<<"Age: "<<p1.age<<endl;
  cout<<"Salary: "<<p1.salary;
  return 0;
}
To download raw file Click Here

Output

Enter Full name: Ram
Enter age: 20
Enter salary: 20000
Displaying Information.
Name: Ram
Age: 20
Salary: 20000

Basic Programs


Flow Control

IF Statement Examples


Switch Case


Goto Statement


Break and Continue


While Loop


Do While Loop


For Loop


Friend Function in C++


String Examples


Array Examples


Structure Examples


Structure & Pointer Examples


Structure & Functions Examples


Enumeration Examples


Template Examples


Functions


Inheritance Examples

Hierarchical Inheritance


Hybrid Inheritance


Multilevel Inheritance


Multiple Inheritance


Single Level Inheritance


Class and Objects

Constructor Example


Destructor Example


Operator Overloading Example


Operator and Function Example


List of Programs


Pointer Examples


Memory Management Examples


Pointers and Arrays


Virtual Function Examples



Learn All in Tamil © Designed & Developed By Tutor Joes