Computer Science, asked by munasingh11003, 6 months ago

give the example of two derived data type?


Answers

Answered by Faouzia
0

Answer:

here

Explanation:

Derived data type : These data types are defined by user itself. Like, defining a class in C++ or a structure. These include Arrays, Structures, Class, Union, Enumeration, Pointers etc.

// C++ program to illustrate pointer

// as derived data type

#include <iostream>

using namespace std;

// main method

int main()

{

// integer variable

int variable = 10;

// Pointer for storing address

int* pointr;

// Assigning address of variable to pointer

pointr = &variable;

cout << "Value of variable = " << variable;

// cout << "\nValue at pointer = "<< pointr;

cout << "\nValue at *pointer = "<< *pointr;

return 0;

}

// This code is contributed by shubhamsingh10

Output:

Value of variable = 10

Value at *pointer = 10

// C++ program to illustrate array

// derived data type

#include <bits/stdc++.h>

using namespace std;

// main method starts from here

int main()

{

// array of size 5

int a[5] = { 1, 2, 3, 4, 5 };

// indexing variable

int i;

for (i = 0; i < 5; i++)

cout << ("%d ", a[i]);

return 0;

}

// This code is contributed by

Output:

1 2 3 4 5

Similar questions