ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Slides:



Advertisements
Similar presentations
What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
Advertisements

C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Sort the given string, without using string handling functions.
More on Functions Programming. COMP104 Lecture 19 / Slide 2 Passing Parameters by Reference l To have a function with multiple outputs, we have to use.
Arrays An array is a sequence of objects all of which have the same type. The objects are called the elements of the array and are numbered consecutively.
#include using namespace std; void main() { int a[3]={10,11,23}; for(int i=0;i
Chapter 4 Summation.
Multiple-Subscripted Array
Pass by Reference. COMP104 Pass by Reference / Slide 2 Passing Parameters by Reference * To have a function with multiple outputs, we have to use pass.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Objectives: In this chapter, you will: Know the different between struct and array.
CHAPTER 7 DATA INPUT OUTPUT Prepared by: Lec. Ghader R. Kurdi.
1 Topic: Array Topic: Array. 2 Arrays Arrays In this chapter, we will : Learn about arrays Learn about arrays Explore how to declare and manipulate data.
Lecture 4 Function example. Example1 int max (int a, int b) { int c; if (a > b) c = a; else c = b; return (c); } void main ( ) {int x, y; cin>>x>>y; cout.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
Arrays.
Review. Problem 1 What is the output of the following piece of code void increment(int x) { x++; } int main() { int y = 10; increment(y); cout
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Multi-dimensional Array 1 Multi-dimensional array refers to an array with more than one index. It is a logical representation. On physical storage, the.
Exception Handling How to handle the runtime errors.
LESSON 2 Basic of C++.
Computer Skills2 / Scientific Colleges 1 Arrays Topics to cover: Arrays Data Types One-dimensional Arrays Two-dimensional Arrays.
C++ CODES PART#04 1 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT.
LESSON 2 Basic of C++.
2-D Array.
Two Dimensional Array Mr. Jacobs.
Introduction to Programming
Operator Overloading.
Programming fundamentals 2 Chapter 1:Array
Multi-dimensional Array
ARRAYS An array is a sequence of data item of homogeneous value(same type). Arrays are of two types: 1. One-dimensional arrays 2. Multi-Dimensional arrays.
C++ Arrays.
CS 1430: Programming in C++.
Programming -2 برمجة -2 المحاضرة-5 Lecture-5.
Array Data Structure Chapter 6
Array Data Structure B.Ramamurthy 11/21/2018 B.Ramamurthy.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Working With Arrays.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Data type List Definition:
Arrays November 8, 2017.
הרצאה 03 אבני היסוד של תוכנית ב- C
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Counting Loops.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
C++ Programming Lecture 16 Arrays – Part III
The Run-Time Stack and Reference Parameters
Lecture 12 Oct 16, 02.
CS150 Introduction to Computer Science 1
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Structure As Function Arguments
CS150 Introduction to Computer Science 1
Arrays Topics to cover: Arrays Data Types One-dimensional Arrays
CS150 Introduction to Computer Science 1
Arrays of Two-Dimensions
CHAPTER 2 Arrays and Vectors.
Array Data Structure Chapter 6
Function Overloading.
C++ winter2008(by:J.Razjouyan)
CS150 Introduction to Computer Science 1
Fundamental Programming
CHAPTER 2 Arrays and Vectors.
Example 1 Ask the user to type10 integers of an array T1 and 10 integers of an array T2. Put into T3, an array with 20 integers : the sum of the elements.
Algorithms and Time Complexity
ENGR.SABA MUGHAL FROM COMPUTER SYSTEM DEPARTMENT
TOPIC: FUNCTION OVERLOADING
ENGR.SABA MUGHAL FROM COMPUTER SYSTEM DEPARTMENT
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
CS150 Introduction to Computer Science 1
Data Structure(s) A way of storing and organizing data in a computer so that it can be used efficiently. e.g. Arrays Linked Lists stacks Queues Trees.
Presentation transcript:

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT C++ CODES PART#11 COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT SIMPLE ARRAY PROGRAM #include<constream.h> void main() {clrscr(); int age[4]; for(int j=0;j<4;j++) { COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue…. cout<<"enter an age:"; cin>>age[j]; } for(j=0;j<4;j++) cout<<"you entered"<<age[j]<<endl; getch(); COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT OUTPUT….. COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Averaging array elements #include<constream.h> void main() {clrscr(); const int size=6; double sales [size]; cout<<"enter sales for 6 days\n"; for(int j=0;j<size;j++) COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue… cin>>sales[j]; double total=0; for(j=0;j<size;j++) total+=sales[j]; double average=total/size; cout<<"average="<<average<<endl; getch();} COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Initialize an array #include<constream.h> void main() { clrscr(); float a[7]={4.5,1.4,7.5,9.5,6.5,3.6,7.8}; for(int i=0;i<7;i++) cout<<"a["<<i<<"]="<<a[i]<<","; getch();} COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output… COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Multidimensional array #include <constream.h> const int SIZE1=3; const int SIZE2=5; void main() { clrscr(); COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue…. int a[SIZE1][SIZE2]; cout << "Enter 15 integer, 5 per row: "<< endl; for (int i=0; i<3; i++) { cout << "Row " << i+1 << ":" << endl; for (int j=0; j < 5; j++) COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue… cin >> a[i][j]; } // end for(i) for (i = 0; i < 3 ; i++) { for (int j=0; j<5 ; j ++) COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue… cout << a[i][j] << " "; cout << endl; }// end main6 getch(); } COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT NICE WORDINGS… Tabeyat ki Narmi aur Sakhawat, insan ko Dushmnon k dilon main b Mehboob bana deti hai….. AY ALLAH PAK, jab maine tujh se nahi manga tab bhi tu ne mujhe ataa kiya ... tou ye kaise mumkin hai k main tujh se mangon or tu ataa na kare…… COPYRIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT