Quraish_065_CS2b_LAb#9.docx - Bahria University Lahore Campus Department of Computer Science Lab Journal 09(Spring 2020 Course Course Code Faculty\u2019s

# Quraish_065_CS2b_LAb#9.docx - Bahria University Lahore...

This preview shows page 1 - 3 out of 4 pages.

Bahria University, Lahore Campus Department of Computer Science Lab Journal 09 (Spring 2020) Course: Computer Programming Lab Date: _______________ Course Code: CSL-113 Max Marks: 30 Faculty’s Name: Numan Aslam Lab Engineer: Tayyab Mir Name: Quraish AmeerEnroll No: 03-134192-065 Class: BSCS 2(b) Objective(s): To Understand about: 1. Apply Arrays in C++ 2. Use of One Dimesional Array Lab Tasks: // Output Elements Square ======== ======= 0 0 1 1 2 4 3 9 4 16 ----------------------------- For Instructor Use Only -----------------------------------Lab Grading Sheet :
Enrollment Number: ____________________________ Task Max Mark s Obtained Marks Comments( if any ) 1. 10 2. 10 3. 10 Total 30 Signature: Note : Attempt all tasks and get them checked by your Lab. Instructor. **Provide solution of each task and screenshot of output at the end of that task** Task 1 Write a program to input array elements and output is labeled, like this: < Solution and output of Task 1 > Code: #include <iostream> using namespace std ; int main () { double num [ 5 ]; cout << "Enter 5 numbers: " << endl ; for ( int i = 0 ; i < 5 ; i ++) { cout << "a[" << i + 0 << "] :" ; cin >> num [ i ]; } cout << endl ; cout << "In reverse order, they are: " << endl ; for ( int i = 5 - 1 ; i >= 0 ; i --) { cout << "a[" << i + 0 << "] :" << num [ i ] << endl ; } return 0 ; } Output:

#### You've reached the end of your free preview.

Want to read all 4 pages?

• Spring '19
• ASIM ALI
• Chemistry, Array