DevelopersSociety

Tuesday, December 9, 2014

C++ Tutorial- Program- 13- Structures


Code:

#include<iostream>
using namespace std; 
struct studentpersonalinformation{
string name;
string fathersname;
int dob;
string rollno;
char character;
};
main()
{
studentpersonalinformation studentpersonalinformation1;
    cout<<"Enter your Name:";
    cin>>studentpersonalinformation1.name;
    cout<<"Enter Fathers Name:";
    cin>>studentpersonalinformation1.fathersname;
    cout<<"Enter your date of birth:";
    cin>>studentpersonalinformation1.dob; 
    cout<<"Enter your roll no:";
    cin>>studentpersonalinformation1.rollno;
    
cout<<"Select Gender(M/F)"<<endl;
    cin>>studentpersonalinformation1.character;
    
 if(studentpersonalinformation1.character=='m'||studentpersonalinformation1.character=='M')
 cout<<"Your Gender: Male"<<endl;
 else if (studentpersonalinformation1.character=='f'||studentpersonalinformation1.character=='F')
 cout<<"Your Gender: Female"<<endl;
 else
 cout<<"Must Select Gender"<<endl;
 }

Output:


No comments:

Post a Comment