SlideShare ist ein Scribd-Unternehmen logo
1 von 5
FP 201 Programming Fundamentals with C++


LAB 6: Array

Learning Outcomes
This Labsheet encompasses activities 6A, 6B, 6C, 6D and 6E

By the end of this lab, students should be able to :
• Understand the basic concept of array
• Differentiate between 1-dimensional array and multi-dimensional array
• Write program using array

Hardware/Software: C++ software (Microsoft Visual Studio, Turbo C++ 5.0/6.0)

Activity 6A
Activity Outcome: Write and compile a program using C++.

The following code illustrates how to declare an array, and access its elements.

Procedure:
Step 1: Type the programs given below
#include<iostream>
using namespace std;
void main()
{
   int i,sum=0;
   int markah [5] ; //declaring an array
   cout<<"Enter marks for memory location :"<<endl;
//input value in array
    for (i=0; i < 5; i++)
    {
        cout<<"markah ["<<i<<"] = ";
        cin>>markah[i];
     }
   cout<<"n"<<endl;//new line
//print location of array
   for (i=0; i < 5; i++)
   {
       cout<< "markah["<<i<<"]" <<"t";
   }
//print element in array
   for (i=0; i < 5; i++)
   {
       cout<< markah[i] <<"tt";
   }
//process element in array
for (i=0; i < 5; i++)
   {
        sum+=markah[i];
   }
cout<<"n"<<sum; //print the sum
}

Step 2: Compile the program.
Step 3: Write the output.
Step 4: Save the program as ________________

                                                                                                           1
FP 201 Programming Fundamentals with C++


 Activity 6B
 Activity Outcome: Write and compile a program using C++.

 The following code illustrates how to declare an array, initialize and access its elements.

 Procedure:
 Step 1: Type the programs given below

 #include<iostream>
 using namespace std;
  void main()
  {
                  char element[6] = {‘Z’,’A’,’I’,’N’,’A’,’L’};

                    cout << "n element 1 : " << element [0] << endl;
                    cout << "n element 2 : " << element [1] << endl;
                    cout << "n element 3 : " << element [2] << endl;
                    cout << "n element 4 : " << element [3] << endl;
                    cout << "n element 5 : " << element [4] << endl;
                    cout << "n element 6 : " << element [5] << endl;
  }

 Step 2: Compile the program.
 Step 3: Write the output.




 Step 4: Save the program as ________________

 Activity 6C
 Activity Outcome: Write and compile a program using C++.

 Program to illustrate how to initialise a character array and display its contents.

Step 1: Type the programs given below and fill in the correct statement in line 4, 5 and 6.

 #include <iostream>
 using namespace std;
 void main()
 {
          char alphabet[ _____ ] = {'A', 'B', 'C', 'D', 'E', ‘F’, ‘G’, ‘H’, ‘I’, ‘J’};
          for ( int i = 0; i <10; ______ )
          cout << _________
          cout << endl;
 }


                                                                                                                   2
FP 201 Programming Fundamentals with C++



 Step 2: Compile the program.
 Step 3: Write the output.




 Step 4: Save the program as ________________

 Activity 6D
 Activity Outcome: Write and compile a program using C++. Printing a sequence in order.

 This program reads five numbers and then prints them in reverse order.

Step 1: Type the programs given below.

 #include<iostream>
 using namespace std;
 void main()
 {
   const int SIZE=5;
   Double a[SIZE];
   cout<<”Enter five number:t;

     for(int i=0; i<SIZE; i++)
                  cin >> a[i];
     cout << “In reverse order: “;
     for(int i=SIZE-1; i>=0; i--)
        cout<<”t”<< a[i];
 }

 Step 2: Compile the program.
 Step 3: Write the output.




 Step 4: Save the program as ________________

                                                                                                       3
FP 201 Programming Fundamentals with C++



 Activity 6E
 Activity Outcome: Write and compile a program using C++.

 This program illustrates how to write program using multi-dimensional array.

Step 1: Type the programs given below.

 #include<iostream>
 using namespace std;
 void main()
 {
         int k, m, multiD_Array[2][3] = {{1, 2, 3}, {4, 5, 6}};

         for (k=0; k<2; k++)
                  for (m=0; m<3; m++)
                  {
                          cout << "element[“ << k <<”][“ << m << “] : ";
                          cout << multiD_Array[k][m] << endl;
                  }
         cout << “n”;
         for (k=0; k<2; k++)
                  for (m=0; m<3; m++)
                  {
                          cout << “nEnter number : ”;
                          cin >> multiD_Array[k][m];
                  }
         cout << “nn”;
         for (k=0; k<2; k++)
                  for (m=0; m<3; m++)
                  {
                          cout << "element[“ << k <<”][“ << m << “] : ";
                          cout << multiD_Array[k][m] << endl;
                  }
 }

 Step 2: Compile the program.
 Step 3: Write the output.




 Step 4: Save the program as ________________



                                                                                                          4
FP 201 Programming Fundamentals with C++




LAB Exercise 6: Array
  1. Declare an array with array size of 10 elements, type double, and initialize the elements to 0.
  2. Write a program using array that can sort the list of five number entered by user.
  3. Write a program to display values in 2 dimensional arrays as in the given table below.
                                         9      7        5
                                         6      8        10

      Display of Output:
                               Pizza                KFC           McDonalds
      Man                        9                   7                 5
      Woman                      6                   8                 1




                                                                                                         5

Weitere ähnliche Inhalte

Was ist angesagt?

Declaring friend function with inline code
Declaring friend function with inline codeDeclaring friend function with inline code
Declaring friend function with inline codeRajeev Sharan
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Aman Deep
 
C++ project
C++ projectC++ project
C++ projectSonu S S
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 solIIUM
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++varun arora
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 studrohassanie
 
What is new in sulu 2.0
What is new in sulu 2.0What is new in sulu 2.0
What is new in sulu 2.0danrot
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQLvikram mahendra
 
C programming Lab 2
C programming Lab 2C programming Lab 2
C programming Lab 2Zaibi Gondal
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THSHAJUS5
 
Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Rushil Aggarwal
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solvingSyed Umair
 
Assignment Examples Final 07 Oct
Assignment Examples Final 07 OctAssignment Examples Final 07 Oct
Assignment Examples Final 07 OctSriram Raj
 

Was ist angesagt? (20)

Declaring friend function with inline code
Declaring friend function with inline codeDeclaring friend function with inline code
Declaring friend function with inline code
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
C++ project
C++ projectC++ project
C++ project
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 stud
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
What is new in sulu 2.0
What is new in sulu 2.0What is new in sulu 2.0
What is new in sulu 2.0
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 
C programming Lab 2
C programming Lab 2C programming Lab 2
C programming Lab 2
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
 
Cs practical file
Cs practical fileCs practical file
Cs practical file
 
Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
 
Assignment Examples Final 07 Oct
Assignment Examples Final 07 OctAssignment Examples Final 07 Oct
Assignment Examples Final 07 Oct
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
C++ file
C++ fileC++ file
C++ file
 
C test
C testC test
C test
 

Andere mochten auch

Jadual Waktu Sesi JUN 2012
Jadual Waktu Sesi JUN 2012Jadual Waktu Sesi JUN 2012
Jadual Waktu Sesi JUN 2012rohassanie
 
Labsheet 7 FP 201
Labsheet 7 FP 201Labsheet 7 FP 201
Labsheet 7 FP 201rohassanie
 
Course outline FP202 - Dis 2012
Course outline FP202 - Dis 2012Course outline FP202 - Dis 2012
Course outline FP202 - Dis 2012rohassanie
 
Chapter 3 part 2
Chapter 3 part 2Chapter 3 part 2
Chapter 3 part 2rohassanie
 
Single level directory structure.55
Single level directory structure.55Single level directory structure.55
Single level directory structure.55myrajendra
 
File management
File managementFile management
File managementMohd Arif
 

Andere mochten auch (8)

Labsheet 5
Labsheet 5Labsheet 5
Labsheet 5
 
Jadual Waktu Sesi JUN 2012
Jadual Waktu Sesi JUN 2012Jadual Waktu Sesi JUN 2012
Jadual Waktu Sesi JUN 2012
 
Labsheet 7 FP 201
Labsheet 7 FP 201Labsheet 7 FP 201
Labsheet 7 FP 201
 
Course outline FP202 - Dis 2012
Course outline FP202 - Dis 2012Course outline FP202 - Dis 2012
Course outline FP202 - Dis 2012
 
Chapter 3 part 2
Chapter 3 part 2Chapter 3 part 2
Chapter 3 part 2
 
Lab ex 1
Lab ex 1Lab ex 1
Lab ex 1
 
Single level directory structure.55
Single level directory structure.55Single level directory structure.55
Single level directory structure.55
 
File management
File managementFile management
File management
 

Ähnlich wie Labsheet 6 - FP 201

Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 studrohassanie
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALPrabhu D
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++Marco Izzotti
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startednoahjamessss
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedgovendaagoovenda
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.combellflower82
 
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
CLASS XII COMPUTER SCIENCE MONTHLY TEST  PAPERCLASS XII COMPUTER SCIENCE MONTHLY TEST  PAPER
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPERRc Os
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com amaranthbeg143
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   llflowe
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   bellflower42
 

Ähnlich wie Labsheet 6 - FP 201 (20)

Labsheet1stud
Labsheet1studLabsheet1stud
Labsheet1stud
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 stud
 
Ch7
Ch7Ch7
Ch7
 
Ch7
Ch7Ch7
Ch7
 
Session 5-exersice
Session 5-exersiceSession 5-exersice
Session 5-exersice
 
Labsheet 4
Labsheet 4Labsheet 4
Labsheet 4
 
Labsheet2
Labsheet2Labsheet2
Labsheet2
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
C++ Question
C++ QuestionC++ Question
C++ Question
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
 
Devry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-startedDevry cis-170-c-i lab-1-of-7-getting-started
Devry cis-170-c-i lab-1-of-7-getting-started
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.com
 
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
CLASS XII COMPUTER SCIENCE MONTHLY TEST  PAPERCLASS XII COMPUTER SCIENCE MONTHLY TEST  PAPER
CLASS XII COMPUTER SCIENCE MONTHLY TEST PAPER
 
P3
P3P3
P3
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   
 
Lab 1
Lab 1Lab 1
Lab 1
 

Mehr von rohassanie

FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6rohassanie
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2rohassanie
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 
FP 202 - Chapter 5
FP 202 - Chapter 5FP 202 - Chapter 5
FP 202 - Chapter 5rohassanie
 
Chapter 3 part 1
Chapter 3 part 1Chapter 3 part 1
Chapter 3 part 1rohassanie
 
FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3rohassanie
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2rohassanie
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2) rohassanie
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1rohassanie
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3 rohassanie
 
Chapter 1 part 3
Chapter 1 part 3Chapter 1 part 3
Chapter 1 part 3rohassanie
 
Chapter 1 part 2
Chapter 1 part 2Chapter 1 part 2
Chapter 1 part 2rohassanie
 
Chapter 1 part 1
Chapter 1 part 1Chapter 1 part 1
Chapter 1 part 1rohassanie
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++rohassanie
 

Mehr von rohassanie (20)

FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6
 
Fp201 unit5 1
Fp201 unit5 1Fp201 unit5 1
Fp201 unit5 1
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2
 
Fp201 unit4
Fp201 unit4Fp201 unit4
Fp201 unit4
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
FP 202 - Chapter 5
FP 202 - Chapter 5FP 202 - Chapter 5
FP 202 - Chapter 5
 
Chapter 3 part 1
Chapter 3 part 1Chapter 3 part 1
Chapter 3 part 1
 
FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3
 
Chapter 1 part 3
Chapter 1 part 3Chapter 1 part 3
Chapter 1 part 3
 
Chapter 1 part 2
Chapter 1 part 2Chapter 1 part 2
Chapter 1 part 2
 
Chapter 1 part 1
Chapter 1 part 1Chapter 1 part 1
Chapter 1 part 1
 
Unit 3
Unit 3Unit 3
Unit 3
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
Fp201 unit1 1
Fp201 unit1 1Fp201 unit1 1
Fp201 unit1 1
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 

Kürzlich hochgeladen

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Labsheet 6 - FP 201

  • 1. FP 201 Programming Fundamentals with C++ LAB 6: Array Learning Outcomes This Labsheet encompasses activities 6A, 6B, 6C, 6D and 6E By the end of this lab, students should be able to : • Understand the basic concept of array • Differentiate between 1-dimensional array and multi-dimensional array • Write program using array Hardware/Software: C++ software (Microsoft Visual Studio, Turbo C++ 5.0/6.0) Activity 6A Activity Outcome: Write and compile a program using C++. The following code illustrates how to declare an array, and access its elements. Procedure: Step 1: Type the programs given below #include<iostream> using namespace std; void main() { int i,sum=0; int markah [5] ; //declaring an array cout<<"Enter marks for memory location :"<<endl; //input value in array for (i=0; i < 5; i++) { cout<<"markah ["<<i<<"] = "; cin>>markah[i]; } cout<<"n"<<endl;//new line //print location of array for (i=0; i < 5; i++) { cout<< "markah["<<i<<"]" <<"t"; } //print element in array for (i=0; i < 5; i++) { cout<< markah[i] <<"tt"; } //process element in array for (i=0; i < 5; i++) { sum+=markah[i]; } cout<<"n"<<sum; //print the sum } Step 2: Compile the program. Step 3: Write the output. Step 4: Save the program as ________________ 1
  • 2. FP 201 Programming Fundamentals with C++ Activity 6B Activity Outcome: Write and compile a program using C++. The following code illustrates how to declare an array, initialize and access its elements. Procedure: Step 1: Type the programs given below #include<iostream> using namespace std; void main() { char element[6] = {‘Z’,’A’,’I’,’N’,’A’,’L’}; cout << "n element 1 : " << element [0] << endl; cout << "n element 2 : " << element [1] << endl; cout << "n element 3 : " << element [2] << endl; cout << "n element 4 : " << element [3] << endl; cout << "n element 5 : " << element [4] << endl; cout << "n element 6 : " << element [5] << endl; } Step 2: Compile the program. Step 3: Write the output. Step 4: Save the program as ________________ Activity 6C Activity Outcome: Write and compile a program using C++. Program to illustrate how to initialise a character array and display its contents. Step 1: Type the programs given below and fill in the correct statement in line 4, 5 and 6. #include <iostream> using namespace std; void main() { char alphabet[ _____ ] = {'A', 'B', 'C', 'D', 'E', ‘F’, ‘G’, ‘H’, ‘I’, ‘J’}; for ( int i = 0; i <10; ______ ) cout << _________ cout << endl; } 2
  • 3. FP 201 Programming Fundamentals with C++ Step 2: Compile the program. Step 3: Write the output. Step 4: Save the program as ________________ Activity 6D Activity Outcome: Write and compile a program using C++. Printing a sequence in order. This program reads five numbers and then prints them in reverse order. Step 1: Type the programs given below. #include<iostream> using namespace std; void main() { const int SIZE=5; Double a[SIZE]; cout<<”Enter five number:t; for(int i=0; i<SIZE; i++) cin >> a[i]; cout << “In reverse order: “; for(int i=SIZE-1; i>=0; i--) cout<<”t”<< a[i]; } Step 2: Compile the program. Step 3: Write the output. Step 4: Save the program as ________________ 3
  • 4. FP 201 Programming Fundamentals with C++ Activity 6E Activity Outcome: Write and compile a program using C++. This program illustrates how to write program using multi-dimensional array. Step 1: Type the programs given below. #include<iostream> using namespace std; void main() { int k, m, multiD_Array[2][3] = {{1, 2, 3}, {4, 5, 6}}; for (k=0; k<2; k++) for (m=0; m<3; m++) { cout << "element[“ << k <<”][“ << m << “] : "; cout << multiD_Array[k][m] << endl; } cout << “n”; for (k=0; k<2; k++) for (m=0; m<3; m++) { cout << “nEnter number : ”; cin >> multiD_Array[k][m]; } cout << “nn”; for (k=0; k<2; k++) for (m=0; m<3; m++) { cout << "element[“ << k <<”][“ << m << “] : "; cout << multiD_Array[k][m] << endl; } } Step 2: Compile the program. Step 3: Write the output. Step 4: Save the program as ________________ 4
  • 5. FP 201 Programming Fundamentals with C++ LAB Exercise 6: Array 1. Declare an array with array size of 10 elements, type double, and initialize the elements to 0. 2. Write a program using array that can sort the list of five number entered by user. 3. Write a program to display values in 2 dimensional arrays as in the given table below. 9 7 5 6 8 10 Display of Output: Pizza KFC McDonalds Man 9 7 5 Woman 6 8 1 5