-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcars.cpp
More file actions
63 lines (53 loc) · 1.11 KB
/
Copy pathcars.cpp
File metadata and controls
63 lines (53 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <string.h>
using namespace std;
struct car
{
string name;
string color;
int maxspeed;
int model;
void fun(car n)
{
cout << n.name << endl;
}
};
car read_return( car &s )
{
cout << "Enter the Name: " << endl;
cin >> s.name;
cout << "Enter the Color: " << endl;
cin >> s.color;
cout << "Enter the Maxspeed: " << endl;
cin >> s.maxspeed;
cout << "Enter the Model: " << endl;
cin >> s.model;
return s;
}
int main()
{
//Structures withe pointer
car *n;
car b = {"A", "C", 200, 2011};
n = &b;
cout << n->color << endl;
//Structures withe inside function
car m = {"Kia"};
m.fun(m);
//Structures withe function
car v;
read_return(v);
car h;
h = v;
cout << h.name << endl;
//Structures withe if & else
car x = {"BMW", "Blue", 250, 2016};
car y = {"Mercedes", "Red", 300, 2016};
if (x.maxspeed > y.model)
cout << "X graeter than Y\n";
else
cout << "Y graeter than X\n";
int arr[5] = {1,2,3};
cout << arr[0] << endl;
cout << y.name;
}