Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
36 views
SP23 - CSC211 - Data Structures & Algorithms - LAB - W01
Uploaded by
Malik Zohaib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save SP23 - CSC211 - Data Structures & Algorithms - LAB... For Later
Download
Save
Save SP23 - CSC211 - Data Structures & Algorithms - LAB... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
36 views
SP23 - CSC211 - Data Structures & Algorithms - LAB - W01
Uploaded by
Malik Zohaib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save SP23 - CSC211 - Data Structures & Algorithms - LAB... For Later
Carousel Previous
Carousel Next
Save
Save SP23 - CSC211 - Data Structures & Algorithms - LAB... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 12
Search
Fullscreen
Lab 01 C++ Revision and Array List Objective: In this lab, students will get familiar with the new language C+ and its IDE with the help of simple programs that will clear the syntax of the language. Beside learning the basics of C++ like control statements, functions, arrays, ete., you will also learn the concept of Array List. Activity Outcomes: This lab te © Basic syntax of C++ ches you the following topics: © Data types and operators in C++ © Control flow statements in C++ © Arrays and Functions Instructor Note: As a pre-lab activity, read fundamental concepts from the text book * Deitel, H., Prentice Hall, 2019”. + How to Program, Deitel1) Useful Concepts C+, as we all know is an extension to C language and was developed by Bjarne stroustrup at bell labs. C+ is an intermediate level language, as it comprises a confirmation of both high level and low level language features Following features of C++ makes it a stronger language than C, 1. There is Stronger Type Checking in C+ 2. C+ supports and allows user defined operators (i.e Operator Overloading) and function overloading is also supported init 3. Exception Handling is there in C+ 4, Inline Functions in C++ instead of Macros in C language. Inline functions make complete funtion body act like Macro, safely. ‘Variables can be declared anywhere in the program in C--+, but must be declared before they are used, Installing GNU C/C++ Compiler Install GCC at Windows you need to install MinGW. To install MinGW, go to the MinGW homepage, www.mingw.org, and follow the link to the MinGW download page. Download the latest version of the MinGW installation program which should be named MinGW-
exe, While installing MinGW, at a minimum, you must install gec-core, geo-g++, binutils, and the MinGW runtime, but you may wish to install more, Add the bin subdirectory of your MinGW installation to your PATH environment variable so that ‘you can specify these tools on the command line by their simple names. When the installation is complete, you will be able to run gee, g++, ar, ranlib, diltool, and several other GNU tools from the Windows command line, IDE for coding ‘The IDE we will be using is Dev-C++. Today we will clear our concepts regarding the syntax of C++ with the help of small programs. Note: we use cin for input and cout for output/print At start of your program always use i#include
using namespace std;Shorteut Keys: # Press F10 to compile # Press F9 to run the complied program. * Press F11 to compile and run the program. ‘© For functions in C++ you will have to define them before writing the main method and the main methods always return 0; 2) Solved Lab Activites ‘Allocated Time | Level of Complexity | CLO Mapping Activity T mins Low CLO-4 Activity 2 Smins Low CLO-4 Activity 3 Smins Low CLO-4 mins Tow CLo-4 Activity 5 mins Low CLO-4 Activity 6 Smins Tow CLO-4 Activity 7 F mins Tow CLO-4 Activity 8 S mins Low CLO-4 Activity 9 S mins Tow CLO-4 Activity 10 mins Tow CLO-4 Activity TT Fmins Tow C04 Activity 12 F mins Low CLO-4 Activity 1: ‘Single Line, Multi Line comments and basic Input/Output in C++. Solution:#include
using namespace std; int main() e<<"Hello Wo! return 0; Output ‘The output will be “Hello World!”. Activity 2: Variables are containers for storing data values. In C++, there are different types of variables (defined with different keywords), for example + int stores integers (whole numbers), without decimals, such as 123 ot -123 + double - stores floating point numbers, with decimals, such as 19.99 or -19.99 + char - stores single characters, such as '' or 'B', Char values are surrounded by single quotes + string - stores text, such as "Hello World’, String values are surrounded by double quotes + bool - stores values with two states: true or false Solution: Finclude
using namespace std; int main () { tial value undetermined‘Output Value present in result variable will be shown on Screen Activity 3: Using cin, extraction operator (>>) and cout (<<). cin iJava program to illustrate enhanced for loop mespace int main () a> stds a) number: "; // xe // Get user" input "Your numbe: ‘splay the input keyboard Output ‘Type a number: 100 ‘Your number is: 100 suppose user enters 100string mystring; different string conte return 0; jal string content ‘This is a different string content Activity 5: Write a program to use arithmetic operators in C++ Finclade
int main () ana; // equivalent to a-at2 OutputAc ity 6: Write a program to use relational operators in C++ bas (@b) 2a: be cout << ¢ << "n'y Output 7 Activity 7: Write a program to use if-else statement in C++ Finclude
int main () int x7 cin>>xs if (x > 0) cout << "% i else if (x < 0) cout << Mx ds 10Output ‘The ouput depends upon the value of “x’ entered by the user, the output will be either x is positive or xis negative or xis 0. Act ity 8: Write a program to use while loop in C++ while (n>0) { cout
using namespace std; int main () { string str; do { cout << "Enter text: "7 getline (cin,str); cout << "You entered: " << str << "\n'y J while (str != "goodbye") ; ‘Output Program repeatedly takes a string as input then displays it say! types goodbye. Activity 10: Write a program to apply the switch statements. 1g “You entered...” Until user Finclude
using namespace std; int main () break; case 2 << "Tuesday"; case 3: ‘cout. << break; tiiednesday"; 2rsday", "ppiday"; Saturday"; Output Outputs "Thursday" as variable day is Activity 11: Write a program that will add two numbers in a function and call that function in main. Finclade
int addition (int a, int b) 2 = addition (5, cout << "The result is "<< 2; BOutput ‘The result is 8 Activity 12: Write a program to use the concept of Arrays in C++ Finclude
using namespace std; int foo {] = {16, 2, 77, 40, 12071}; int n, result=0; cout << result, ‘Output 12206 3) Graded Lab Tasks Note: The instructor can design graded lab activities according to the level of difficulty and complexity of the solved lab activities, The lab tasks assigned by the instructor should be evaluated in the same lab Lab Task 1 Write down a program that find [X° , where input for X and starting and stopping value is entered by the user. 14Lab Task 2 Write the computer program to apply the concepts of Array List. The array list will include the following fimetions Insert the value at end of the list Insert the value at start ofthe list Insert the value after specific value Insert the value before specific value Display the array list Delete the value from end of the list Delete the value from start of the list Delete specific value Lab Task 3 Using, while loop apply liear search on the Array List you developed in Lab Task 2. 15
You might also like
Data Structure and Algorithms Lab Manuel in C++
PDF
No ratings yet
Data Structure and Algorithms Lab Manuel in C++
120 pages
181-lab-v2.1
PDF
No ratings yet
181-lab-v2.1
60 pages
Dsa Lab Manual Actual
PDF
No ratings yet
Dsa Lab Manual Actual
47 pages
OOP Through C++ Lab Manual
PDF
No ratings yet
OOP Through C++ Lab Manual
51 pages
(M1-TECHNICAL) Done
PDF
No ratings yet
(M1-TECHNICAL) Done
16 pages
Solution Manual for Starting Out with C++: Early Objects, 8/E 8th Edition : 013336092X download
PDF
100% (2)
Solution Manual for Starting Out with C++: Early Objects, 8/E 8th Edition : 013336092X download
43 pages
CS 101B C++ Lab Manual
PDF
No ratings yet
CS 101B C++ Lab Manual
74 pages
Programming Fundamentals-SEPF-121 - Lab Manual
PDF
No ratings yet
Programming Fundamentals-SEPF-121 - Lab Manual
43 pages
(M1-TECHNICAL) Done Navor
PDF
No ratings yet
(M1-TECHNICAL) Done Navor
15 pages
2024-CS-00 PF Lab Manual
PDF
No ratings yet
2024-CS-00 PF Lab Manual
6 pages
Intoduction To C++ - Hipolito - CPP
PDF
No ratings yet
Intoduction To C++ - Hipolito - CPP
3 pages
f8486976 Learn Professional Programming Skill in C Programming Language
PDF
No ratings yet
f8486976 Learn Professional Programming Skill in C Programming Language
814 pages
PraList C++
PDF
No ratings yet
PraList C++
5 pages
Course Outline Introduction to Programming
PDF
No ratings yet
Course Outline Introduction to Programming
2 pages
Computer Fundamentals Labes Report (1-8) - Shabbir Hussain (RP-22-EE-416)
PDF
No ratings yet
Computer Fundamentals Labes Report (1-8) - Shabbir Hussain (RP-22-EE-416)
125 pages
PDF Basic Tasks!
PDF
No ratings yet
PDF Basic Tasks!
7 pages
Febin Oops
PDF
No ratings yet
Febin Oops
34 pages
Programming Language Lab PDF
PDF
No ratings yet
Programming Language Lab PDF
49 pages
Lab Report Awais Mahmood
PDF
No ratings yet
Lab Report Awais Mahmood
56 pages
Aug24 PGDAC_CPP Syllabus_72hr
PDF
No ratings yet
Aug24 PGDAC_CPP Syllabus_72hr
5 pages
Lab Manual Programming Fundamentals: Submitted To: XYZ Submitted By: XYZ Section: A/B Roll Number: 123
PDF
No ratings yet
Lab Manual Programming Fundamentals: Submitted To: XYZ Submitted By: XYZ Section: A/B Roll Number: 123
24 pages
Programming1 Lab#2
PDF
No ratings yet
Programming1 Lab#2
11 pages
PF Lab manual
PDF
No ratings yet
PF Lab manual
71 pages
Programming 1 - Sample Milestone Assignment 2 Questions: Milestone 2 On 10/25/2021, In-Class Released: October 21, 2021
PDF
No ratings yet
Programming 1 - Sample Milestone Assignment 2 Questions: Milestone 2 On 10/25/2021, In-Class Released: October 21, 2021
7 pages
Geronimo Le3
PDF
No ratings yet
Geronimo Le3
14 pages
HAL 102 - Lab
PDF
No ratings yet
HAL 102 - Lab
43 pages
Access Solution Manual for Starting Out with C++: Early Objects, 8/E 8th Edition : 013336092X All Chapters Immediate PDF Download
PDF
100% (22)
Access Solution Manual for Starting Out with C++: Early Objects, 8/E 8th Edition : 013336092X All Chapters Immediate PDF Download
43 pages
7. Programming Fundamentals
PDF
No ratings yet
7. Programming Fundamentals
15 pages
CPLAB00
PDF
No ratings yet
CPLAB00
7 pages
CMS 102-2 Lab Manual
PDF
No ratings yet
CMS 102-2 Lab Manual
43 pages
Manual
PDF
No ratings yet
Manual
51 pages
SCSE202
PDF
No ratings yet
SCSE202
2 pages
Week 1: Getting Started With C++: Background
PDF
No ratings yet
Week 1: Getting Started With C++: Background
63 pages
The Basic Structure of The C/C++ Language: I. Objectives
PDF
No ratings yet
The Basic Structure of The C/C++ Language: I. Objectives
8 pages
OOPS Manual
PDF
No ratings yet
OOPS Manual
39 pages
StMat Computer SC
PDF
No ratings yet
StMat Computer SC
45 pages
C Lectures
PDF
No ratings yet
C Lectures
484 pages
MCIS 6204 - Data Structure & Algorithms (Labs) - Day1
PDF
No ratings yet
MCIS 6204 - Data Structure & Algorithms (Labs) - Day1
7 pages
CP - Unit 1 - 2
PDF
No ratings yet
CP - Unit 1 - 2
43 pages
CPP 2
PDF
No ratings yet
CPP 2
87 pages
lab1
PDF
No ratings yet
lab1
3 pages
Eee 1110
PDF
No ratings yet
Eee 1110
109 pages
C++ Basics
PDF
100% (1)
C++ Basics
46 pages
Lab Manual Week 10
PDF
No ratings yet
Lab Manual Week 10
5 pages
C++ Notes
PDF
No ratings yet
C++ Notes
34 pages
2013 Syllabus 11 Computer Science
PDF
No ratings yet
2013 Syllabus 11 Computer Science
5 pages
01 QP SP 2 Cs
PDF
No ratings yet
01 QP SP 2 Cs
12 pages
(C++PROGRAMMING) MIT2 S998S12 Lab0 241031 140138
PDF
No ratings yet
(C++PROGRAMMING) MIT2 S998S12 Lab0 241031 140138
19 pages
C++ advance notes/Ebook
PDF
No ratings yet
C++ advance notes/Ebook
116 pages
CS 102 Lab 1
PDF
0% (1)
CS 102 Lab 1
18 pages
DS-COMP2117-Lab Manual
PDF
No ratings yet
DS-COMP2117-Lab Manual
6 pages
G64OOS LabManual v2012 - 1.0
PDF
No ratings yet
G64OOS LabManual v2012 - 1.0
35 pages
Us C++ 2021 01
PDF
No ratings yet
Us C++ 2021 01
25 pages
C++ Programming Language: Basics
PDF
100% (1)
C++ Programming Language: Basics
49 pages
Air University: Objective
PDF
No ratings yet
Air University: Objective
5 pages
(eBook PDF) C++ Without Fear: A Beginner's Guide That Makes You Feel Smart 3rd Edition instant download
PDF
100% (2)
(eBook PDF) C++ Without Fear: A Beginner's Guide That Makes You Feel Smart 3rd Edition instant download
38 pages
Hashing Updated
PDF
No ratings yet
Hashing Updated
26 pages
Graphs Intro + Shortest Path + Traversal
PDF
No ratings yet
Graphs Intro + Shortest Path + Traversal
49 pages
Binary Trees
PDF
No ratings yet
Binary Trees
28 pages
Assignment 1
PDF
No ratings yet
Assignment 1
10 pages
AVL Trees
PDF
No ratings yet
AVL Trees
31 pages
Structural Modeling
PDF
No ratings yet
Structural Modeling
60 pages
Activity
PDF
No ratings yet
Activity
6 pages
SEC Assignment # 2
PDF
No ratings yet
SEC Assignment # 2
14 pages
Melds Apparatus
PDF
100% (1)
Melds Apparatus
4 pages
Comsat S University Islamabad: Course Title: Course Name: Lab: Group Members
PDF
No ratings yet
Comsat S University Islamabad: Course Title: Course Name: Lab: Group Members
3 pages