// simple struct (user defined datatype) program
// using c++
#include <iostream>
using namespace std;
struct student //student is user defind data type
{
int roll_no;
char name;
int age;
};
int main()
{
student a; //a is the object of student
cout << "\nEnter the name of student: ";
cin >> a.name;
cout << "\n Enter your age: ";
cin >> a.age;
cout << "\n enter your roll no: ";
cin >> a.roll_no;
cout << "\n student name is :" << a.name;
cout << "\n age is :" << a.age;
cout << "\n roll no :" << a.roll_no;
}
// using c++
#include <iostream>
using namespace std;
struct student //student is user defind data type
{
int roll_no;
char name;
int age;
};
int main()
{
student a; //a is the object of student
cout << "\nEnter the name of student: ";
cin >> a.name;
cout << "\n Enter your age: ";
cin >> a.age;
cout << "\n enter your roll no: ";
cin >> a.roll_no;
cout << "\n student name is :" << a.name;
cout << "\n age is :" << a.age;
cout << "\n roll no :" << a.roll_no;
}
No comments:
Post a Comment