Professional Documents
Culture Documents
Objective:
The objective of this lab is to implement the declaration, initialization, values assignment, and values
output for primitive and custom data types.
Scope:
This lab focuses on two categories of data types i. Primitive Types (bool, char, int, long, float, double) ii.
Custom Types. Students will be taught the declaration, initialization, data assignment and retrieval from
the variables of these categories. The use of the pointers to access and manipulate the data values will
also be taught to students.
Task 01:
Write a C++ program to declare one variable each of types i. char ii. int iii. float iv. double. Initialize the
declared variables with constant values and output the values of the declared variables using cout
statement.
Objective:
Solution:
Task 02:
Write a C++ program to declare one array of size 5 for each of the following types:
i. char
ii. int
iii. float
iv. double.
Initialize the declared arrays with constant values and output the values of the declared variables using
cout statement.
Note: Use for-loop the iterate over the elements of the array declared during this example.
Objective:
Solution:
Objective:
Declaring the primitive arrays, initializing and output variables using pointers.
Solution:
Task 04:
Objective:
Declaring the primitive type variables, initializing and output variables using pointers.
Solution:
1. Write a program that finds a given number from an array. The elements in the array would be
entered by the user.
2. Write a program that performs the summation of diagonal elements of a matrix of N*N order.
3. Write a program that finds minimum and maximum number from an array and display number and
its memory address
4. Write a program that initializes an integer array of size N with positive values. The program operates
over the array data and outputs the prime numbers from the array.