1//Struct is a compound data type that contains different variables of different types.
2struct Student
3{
4 char stuName[30];
5 int stuRollNo;
6 int stuAge;
7};
8
1
2#include <bits/stdc++.h>
3#include <iostream>
4
5#define ll long long
6
7using namespace std;
8
9struct student{
10 int roll;
11 string name;
12 int age;
13
14 void studentDetails(){
15 cout<<"Name is "<<name<<" Age is "<<age<<" roll no is "<<roll<<endl;
16 }
17};
18
19
20int main(){
21
22 student sumant;
23 sumant.roll = 30;
24 sumant.name = "Sumant Tirkey";
25 sumant.age = 18;
26
27 sumant.studentDetails();
28 cout<<endl;
29
30 return 0;
31}
1struct product {
2 int weight;
3 double price;
4} ;
5
6product apple;
7product banana, melon;