Matrix-Vector Multiplication using friend function
|
|
- Bartholomew Parsons
- 5 years ago
- Views:
Transcription
1 Ex.No Matrix-Vector Multiplication using friend function Aim: To write C++ program to define matrix and vector class, to use function with default argument and to do matrix-vector multiplication using friend function. Algorithm: 1. Declare vector Class 2. Define matrix Class 3. Declare friend function multiply() inside the matrix class 4. Define vector Class 5. Define a static variable in both class to count the No. of objects created. 6. Declare friend function multiply() inside the vector class 7. Define getvector() function with for loop to get the elements for vector 8. Define disvector() function with for loop to display the contents of vector 9. Define getmatrix() function with nested for loops to get the matrix elements 10. Define dismatrix() function with nested for loops to display the matrix 11. Define the multiply() to multiply matrix and vector a. No of Rows in the matrix should be equal to no. of elements in the vector b. Apply the matrix-vector multiplication mechanism: c. Display the resultant matrix in the screen 12. Define main() to create objects and to call the defined functions. Program: #include<iostream.h> #include<conio.h> class Vector; //class declaration needed, because this class referred before it is defined in the //friend function. class Matrix
2 int m[10][10]; int row,col; static int mcount; public: void getmatrix(void); void dispmatrix(void); void dispmcount(); friend void multiply(matrix &, Vector &); ; class Vector int v[10]; int size; static int vcount; public: //default argument is 3 void getvector(int n=3); void dispvector(void); void dispvcount(); friend void multiply(matrix &, Vector &); ; int Matrix::mcount; int Vector::vcount; void Vector::getVector(int n) int i; vcount++; size=n; cout<<"\nenter elements for vector one by one...\n"; for(i=0;i<n;i++) cin>>v[i];
3 void Vector::dispVector() int i; cout<<"\nthe vector elements are...\n"; for ( i=0 ; i<size ; i++ ) cout<<v[i]<<"\t"; void Vector::dispVcount() cout<<"\nno.of Vector objects created:"<<vcount; void Matrix::getMatrix() int i,j; mcount++; cout<<"\nenter the No.of rows and No.of col of the matrix:"; cout<< \nenter the Row Size : ; cin>>row; cout<< \nenter the Column Size : ; cin>>col; cout<<"\nenter the matrix elements:\n"; for(i=0;i<row;i++) for(j=0;j<col;j++) cin>>m[i][j]; void Matrix::dispMatrix() int i, j; cout<<"\nentered matrix is...\n"; for(i=0;i<row;i++)
4 for(j=0;j<col;j++) cout<<m[i][j]<<"\t"; cout<<"\n"; void Matrix::dispMcount() cout<<"\nno.of Matrix objects created:"<<mcount; void multiply(matrix &m1, Vector &v1) int ans[10], i, j; if(v1.size == m1.row) cout<<"\nthe resultant matrix...\n"; for(i=0;i<row;i++) ans[i]=0; for(j=0;j<col;j++) ans[i]+=m1.m[i][j] * v1.v[j]; cout<<ans[i]<<"\t"; else cout<< No of Rows in the matrix should be equal to no. of elements in the vector ; void main() clrscr();
5 int op,ch=1; Vector V; Matrix M; while(ch==1) cout<< \n \n \n \n ; cout<< \nenter Your Option: ; cin>>op; switch(op) case 1: V.getVector(); M.getMatrix(); case 2: V.dispVector(); M.dispMatrix(); case 3: multiply(m,v) case 4: V.dispVcount(); M.dispMcount(); cout<< \npress 1 to continue ; cin>>ch; getch();
6 Input / Output: Enter Your Option:1 Enter elements for vector one by one Enter the No.of rows and No.of col of the matrix: Enter the Row Size : 3 Enter the Column Size : 2 Enter the matrix elements: Press 1 to continue Enter Your Option:2 The vector elements are Entered matrix is
7 2 4 Press 1 to continue1 Enter Your Option: 3 The resultant matrix Press 1 to continue1 Enter Your Option:4 No.Of Vector objects created:1 No.Of Matrix objects created:1 Press 1 to continue1 Enter Your Option:5 Result: Thus the above program defined matrix and vector class, the function getvector defined with default argument used to define the size of the vector and the matrix-vector multiplication done by using friend function.
Downloaded from
Unit-II Data Structure Arrays, Stacks, Queues And Linked List Chapter: 06 In Computer Science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
More informationC++ 8. Constructors and Destructors
8. Constructors and Destructors C++ 1. When an instance of a class comes into scope, the function that executed is. a) Destructors b) Constructors c) Inline d) Friend 2. When a class object goes out of
More informationDELHI PUBLIC SCHOOL TAPI
Loops Chapter-1 There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed
More informationContainer Class and Integrators, Proxy Class EC6301-OOPS AND DATA STRUCTURES
Container Class and Integrators, Proxy Class Container Class A container class is a data type that is capable of holding a collection of items. A container stores many entities and provide sequential or
More informationLooping statement While loop
Looping statement It is also called a Repetitive control structure. Sometimes we require a set of statements to be executed a number of times by changing the value of one or more variables each time to
More informationSample Paper - II Subject Computer Science
Sample Paper - II Subject Computer Science Max Marks 70 Duration 3 hrs Note:- All questions are compulsory Q1) a) What is significance of My Computer? 2 b) Explain different types of operating systems.
More informationThe important features of Object Oriented programming are:
Q.2.a. Briefly explain the features of OOP. Ans. The important features of Object Oriented programming are: 1. Inheritance: Inheritance as the name suggests is the concept of inheriting or deriving properties
More informationC++ is case sensitive language, meaning that the variable first_value, First_Value or FIRST_VALUE will be treated as different.
C++ Character Set a-z, A-Z, 0-9, and underscore ( _ ) C++ is case sensitive language, meaning that the variable first_value, First_Value or FIRST_VALUE will be treated as different. Identifier and Keywords:
More informationOOP THROUGH C++(R16) int *x; float *f; char *c;
What is pointer and how to declare it? Write the features of pointers? A pointer is a memory variable that stores the address of another variable. Pointer can have any name that is legal for other variables,
More informationOBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES
Polymorphism: It allows a single name/operator to be associated with different operations depending on the type of data passed to it. An operation may exhibit different behaviors in different instances.
More informationClassification s of Data Structures
Linear Data Structures using Sequential organization Classification s of Data Structures Types of Data Structures Arrays Declaration of arrays type arrayname [ arraysize ]; Ex-double balance[10]; Arrays
More informationCHAPTER 9 FLOW OF CONTROL
CHAPTER 9 FLOW OF CONTROL FLOW CONTROL In a program statement may be executed sequentially, selectively or iteratively. Every program language provides constructs to support sequence, selection or iteration.
More informationCSE202-Lec#4. CSE202 C++ Programming
CSE202-Lec#4 Functions and input/output streams @LPU CSE202 C++ Programming Outline Creating User Defined Functions Functions With Default Arguments Inline Functions @LPU CSE202 C++ Programming What is
More information1. FIBONACCI SERIES. Write a C++ program to generate the Fibonacci for n terms. To write a C++ program to generate the Fibonacci for n terms.
PROBLEM: 1. FIBONACCI SERIES Write a C++ program to generate the Fibonacci for n terms. AIM: To write a C++ program to generate the Fibonacci for n terms. PROGRAM CODING: #include #include
More informationSchool Management System
School Management System #include #include #include #include #include #include #include struct marks_criteria int sc_min,com_min,arts_min,
More informationInheritance: Single level inheritance:
Inheritance: The mechanism of deriving a new class from old one is called inheritance. The old class is referred to as the base class or parent class and the new class is called the derived class or child
More information---
Bharathi Hr. Sec. School, Reddipatty..1.. A. Prabhakar, M.C.A.,B.Ed., Enter the given text: Heaven from all creatures hides the book of fate. All but the page prescribe the present state. A hero perishes
More informationCOMPUTER SCIENCE PRACTICAL GUIDE [ ENGLISH MEDIUM ]
+2 COMPUTER SCIENCE PRACTICAL GUIDE 2018-19 [ ENGLISH MEDIUM ] NAME : SUBJECT: SCHOOL : Sastra Matriculation Higher Secondary School 1 Kilpennathur, Tiruvannamalai INSTRUCTIONS FOR THE CONDUCT OF PRACTICAL
More informationBLUE PRINT SUBJECT: - COMPUTER SCIENCE(083) CLASS-XI. Unit Wise Marks
BLUE PRINT SUBJECT: - COMPUTER SCIENCE(083) CLASS-XI Unit Wise Marks Unit No. Unit Name Marks 1. COMPUTER FUNDAMENTAL 10 2. PROGRAMMING METHODOLOGY 12 3. INTRODUCTION TO C++ 1. INTRODUCTION TO C++ 3 TOTAL
More informationSample Paper Class XI Subject Computer Sience UNIT TEST II
Sample Paper Class XI Subject Computer Sience UNIT TEST II (General OOP concept, Getting Started With C++, Data Handling and Programming Paradigm) TIME: 1.30 Hrs Max Marks: 40 ALL QUESTIONS ARE COMPULSURY.
More informationUnit 3 Decision making, Looping and Arrays
Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.
More informationFUNCTIONS OMPAL SINGH
FUNCTIONS 1 INTRODUCTION C enables its programmers to break up a program into segments commonly known as functions, each of which can be written more or less independently of the others. Every function
More informationQ2: Write an algorithm to merge two sorted arrays into a third array? (10 Marks) Ans Q4:
Model Answer Benha University 1 st Term (2013/2014) Final Exam Class: 2 nd Year Students Subject: Data Structures Faculty of Computers & Informatics Date: 26/12/2013 Time: 3 hours Examiner: Dr. Essam Halim
More informationMAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-I PART-A 1. What is
More information2. Distinguish between a unary, a binary and a ternary operator. Give examples of C++ operators for each one of them.
1. Why do you think C++ was not named ++C? C++ is a super set of language C. All the basic features of C are used in C++ in their original form C++ can be described as C+ some additional features. Therefore,
More informationSample Paper -V Subject Computer Science Time: 3Hours Note. (i) All questions are compulsory. Maximum Marks: 70 Q.No.1 a. Write the header file for the given function 2 abs(), isdigit(), sqrt(), setw()
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Name: Object Oriented Programming
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may
More informationChapter-13 USER DEFINED FUNCTIONS
Chapter-13 USER DEFINED FUNCTIONS Definition: User-defined function is a function defined by the user to solve his/her problem. Such a function can be called (or invoked) from anywhere and any number of
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes
More informationCOMMON QUARTERLY EXAMINATION SEPTEMBER 2018
i.ne COMMON QUARTERLY EXAMINATION SEPTEMBER 2018 1. a) 12 2. a) Delete 3. b) Insert column 4. d) Ruler 5. a) F2 6. b) Auto fill 7. c) Label 8. c) Master page 9. b) Navigator 10. d) Abstraction 11. d) Void
More informationVOLUME II CHAPTER 9 INTRODUCTION TO C++ HANDS ON PRACTICE PROGRAMS
VOLUME II CHAPTER 9 INTRODUCTION TO C++ HANDS ON PRACTICE PROGRAMS 1. Write C++ programs to interchange the values of two variables. a. Using with third variable int n1, n2, temp; cout
More information:: Computer Science C++ Important Questions ::
:: Computer Science C++ Important Questions :: 1 Write a function in C++, which accepts an integer array and its size as parameters and rearranges the array in descending order. Example: If an array of
More informationIntroduction to computer science C language Homework 4 Due Date: Save the confirmation code that will be received from the system
Introduction to computer science C language Homework 4 Due Date: 20.12.2017 Save the confirmation code that will be received from the system Submission Instructions : Electronic submission is individual.
More information/* Polynomial Expressions Using Linked List*/ #include<stdio.h> #include<conio.h> #include <malloc.h> struct node. int num; int coeff;
/* Polynomial Expressions Using Linked List*/ #include #include #include struct node int num; int coeff; struct node *next; ; struct node *start1 = NULL; struct node *start2
More informationModule Memory and Data Locality
GPU Teaching Kit Accelerated Computing Module 4.5 - Memory and Data Locality Handling Arbitrary Matrix Sizes in Tiled Algorithms Objective To learn to handle arbitrary matrix sizes in tiled matrix multiplication
More informationUNIT III ARRAYS AND STRINGS
UNIT III ARRAYS AND STRINGS Arrays Initialization Declaration One dimensional and Two dimensional arrays. String- String operations String Arrays. Simple programs- sorting- searching matrix operations.
More informationSelection / making decision If statement if-else, if-else-if or nested if Switch Case
SPM 2102 PROGRAMMING LANGUAGE 1 C++ Programming Structure By NORAH MD NOOR 1 Selection / making decision If statement if-else, if-else-if or nested if Switch Case 2 Introduction: Flow of control Normal
More informationPOINTERS - Pointer is a variable that holds a memory address of another variable of same type. - It supports dynamic allocation routines. - It can improve the efficiency of certain routines. C++ Memory
More informationHomework 2 Solutions Group B 1- Write a C++ program to read a students score in Statistics and print if he is successful or failing.
Homework 2 Solutions Group B 1- Write a C++ program to read a students score in Statistics and print if he is successful or failing. int score; cout>score; if ((score>=60)&&(score
More informationCHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++
CHAPTER 9 C++ 1. WRITE ABOUT THE BINARY OPERATORS USED IN C++? ARITHMETIC OPERATORS: Arithmetic operators perform simple arithmetic operations like addition, subtraction, multiplication, division etc.,
More informationArrays in C. By Mrs. Manisha Kuveskar.
Arrays in C By Mrs. Manisha Kuveskar. C Programming Arrays An array is a collection of data that holds fixed number of values of same type. For example: if you want to store marks of 100 students, you
More informationControl Structure and Loop Statements
Control Structure and Loop Statements A C/C++ program executes in sequential order that is the way the instructions are written. There are situations when we have to skip certain code in the program and
More informationChapter4: Data Structures. Data: It is a collection of raw facts that has implicit meaning.
Chapter4: s Data: It is a collection of raw facts that has implicit meaning. Data may be single valued like ID, or multi valued like address. Information: It is the processed data having explicit meaning.
More informationIntroduction to Computer Science Midterm 3 Fall, Points
Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do
More informationSolution: A pointer is a variable that holds the address of another object (data item) rather than a value.
1. What is a pointer? A pointer is a variable that holds the address of another object (data item) rather than a value. 2. What is base address? The address of the nth element can be represented as (a+n-1)
More informationLab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1
Lab 2: Pointers 1. Goals Further understanding of pointer variables Passing parameters to functions by address (pointers) and by references Creating and using dynamic arrays Combing pointers, structures
More information1. a) Attempt any SIX of the following: Marks 12 i) What is Data abstraction?
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationDownloaded from
Unit I Chapter -1 PROGRAMMING IN C++ Review: C++ covered in C++ Q1. What are the limitations of Procedural Programming? Ans. Limitation of Procedural Programming Paradigm 1. Emphasis on algorithm rather
More informationNAMESPACES IN C++ You can refer the Programming with ANSI C++ by Bhushan Trivedi for Understanding Namespaces Better(Chapter 14)
NAMESPACES IN C++ You can refer the Programming with ANSI C++ by Bhushan Trivedi for Understanding Namespaces Better(Chapter 14) Some Material for your reference: Consider following C++ program. // A program
More informationBRAIN INTERNATIONAL SCHOOL. Term-I Class XI Sub: Computer Science Revision Worksheet
BRAIN INTERNATIONAL SCHOOL Term-I Class XI 2018-19 Sub: Computer Science Revision Worksheet Chapter-1. Computer Overview 1. Which electronic device invention brought revolution in earlier computers? 2.
More informationQUESTION BANK UNIT III
QUESTION BANK UNIT III DEPARTMENT: CSE SUB NAME: OBJECT ORIENTED PROGRAMMING SEMESTER III SUB CODE: CS2203 PART A (2 MARKS) 1. What are templates? (AUC DEC 2009) Template is one of the features added to
More informationFunctions. Introduction :
Functions Introduction : To develop a large program effectively, it is divided into smaller pieces or modules called as functions. A function is defined by one or more statements to perform a task. In
More informationKapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class
Chapter 6 Inheritance Extending a Class Introduction; Need for Inheritance; Different form of Inheritance; Derived and Base Classes; Inheritance and Access control; Multiple Inheritance Revisited; Multilevel
More informationSTRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY
STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY Objectives Declaration of 1-D and 2-D Arrays Initialization of arrays Inputting array elements Accessing array elements Manipulation
More informationCOMP322 - Introduction to C++ Lecture 07 - Introduction to C++ classes
COMP322 - Introduction to C++ Lecture 07 - Introduction to C++ classes Dan Pomerantz School of Computer Science 27 February 2012 Why classes? A class can be thought of as an abstract data type, from which
More informationData type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:
Unit IV Pointers and Polymorphism in C++ Concepts of Pointer: A pointer is a variable that holds a memory address of another variable where a value lives. A pointer is declared using the * operator before
More informationCHAPTER 4 FUNCTIONS. 4.1 Introduction
CHAPTER 4 FUNCTIONS 4.1 Introduction Functions are the building blocks of C++ programs. Functions are also the executable segments in a program. The starting point for the execution of a program is main
More informationPROGRAM 1 AIM: Write a program to find the number of vertices, even vertices, odd vertices and the number of edges in a graph.
PROGRAM 1 AIM: Write a program to find the number of vertices, even vertices, odd vertices and the number of edges in a graph. CODE: #include using namespace std; #include #define MAX
More informationArrays. Elementary Data Representation Different Data Structure Operation on Data Structure Arrays
Arrays Elementary Data Representation Different Data Structure Operation on Data Structure Arrays Elementary Data Representation Data can be in the form of raw data, data items and data structure. Raw
More informationcout<< \n Enter values for a and b... ; cin>>a>>b;
CHAPTER 8 CONSTRUCTORS AND DESTRUCTORS 8.1 Introduction When an instance of a class comes into scope, a special function called the constructor gets executed. The constructor function initializes the class
More informationDeveloped By Strawberry
Experiment No. 9 PART A (PART A: TO BE REFFERED BY STUDENTS) A.1 Aim: To study virtual functions and Polymorphism P1: Create a base class called 'SHAPE' having - two data members of type double - member
More informationChapter-14 STRUCTURES
Chapter-14 STRUCTURES Introduction: We have seen variables of simple data types, such as float, char, and int. Variables of such types represent one item of information: a height, an amount, a count, and
More informationCHAPTER : 9 FLOW OF CONTROL
CHAPTER 9 FLOW OF CONTROL Statements-Statements are the instructions given to the Computer to perform any kind of action. Null Statement-A null statement is useful in those case where syntax of the language
More informationImportant Questions 2010 Class-XII-Computer Science
Important Questions 2010 Class-XII-Computer Science I Q.1. Differentiate between primary memory and secondary memory. Give examples of each type of memory. a) The memory inside the CPU is primary memory
More informationUNIT-4 Statements:- Null Statement:- Compound Statement :- Statement Flow Control:- Sequence Construct:- Selection Construct
UNIT-4 Programming in C++ Statements:-Statements are the instructions given to the Computer to perform any kind of action. Null Statement:-A null statement is useful in those case where syntax of the language
More informationKareemNaaz Matrix Divide and Sorting Algorithm
KareemNaaz Matrix Divide and Sorting Algorithm Shaik Kareem Basha* Department of Computer Science and Engineering, HITAM, India Review Article Received date: 18/11/2016 Accepted date: 13/12/2016 Published
More informationPESIT Bangalore South Campus
USN 1 P E PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of ECE INTERNAL ASSESSMENT TEST 2 Date : 03/10/2017 Marks: 40 Subject & Code : Object Oriented Programming
More informationDownloaded S. from Kiran, PGT (CS) KV, Malleswaram STRUCTURES. Downloaded from
Downloaded S. from Kiran, www.studiestoday.com PGT (CS) KV, STRUCTURES WHAT IS A STRUCTURE? Structure is a collection of logically related data. It is also a collection of dissimilar datatype. Downloaded
More informationEXP 1.1 Operator Precedence. #include <iostream.h> Int main() { int a = 20, b = 10, c = 15,d = 5, e; e = (a + b) * c / d;
EXP 1.1 Operator Precedence #include Int main() int a = 20, b = 10, c = 15,d = 5, e; e = (a + b) * c / d; cout
More informationCS 7B - Spring Final Exam
CS 7B - Spring 2018 - Final Exam Write your responses to following questions on this paper, or attach extra, as needed. sentences where appropriate and write out code using proper style and syntax. 1.
More informationUnit-V File operations
Unit-V File operations What is stream? C++ IO are based on streams, which are sequence of bytes flowing in and out of the programs. A C++ stream is a flow of data into or out of a program, such as the
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II Year / Semester: III / V Date: 08.7.17 Duration: 45 Mins
More informationList of Programs included 1. Insertion sort 2. Bubble sort 3. Selection sort 4. Circular Queue 5. Stack implementation using array 6.
List of Programs included 1. Insertion sort 2. Bubble sort 3. Selection sort 4. Circular Queue 5. Stack implementation using array 6. Linear search 7. Binary search (non recursive) 8. Fibonacci with recursion
More informationOBJECTS. An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently.
OBJECTS An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently. Objects that work in associations with each others. Objects that frequently
More informationComputers Programming Course 7. Iulian Năstac
Computers Programming Course 7 Iulian Năstac Recap from previous course Operators in C Programming languages typically support a set of operators, which differ in the calling of syntax and/or the argument
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection) Control Structures A computer can proceed: In sequence Selectively (branch) - making
More informationCSE202- Lec#6. (Operations on CSE202 C++ Programming
Arrays CSE202- Lec#6 (Operations on Arrays) Outline To declare an array To initialize an array Operations on array Introduction Arrays Collection of related data items of same data type. Static entity
More informationClasses. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).
UNITII Classes Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). It s a User Defined Data-type. The Data declared in a Class are called Data- Members
More informationCAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE
CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE a) Mention any 4 characteristic of the object car. Ans name, colour, model number, engine state, power b) What
More informationProgram. SUBJECT: ACP (C - Programming) Array Program. // Find the minimum number from given N element. Prepared By : Dhaval R.
Program // Find the minimum number from given N element. #include #include void main() int a[50],i,n,min; clrscr(); printf("\n Enter array size : "); scanf("%d",&n); printf("\n Enter
More informationDHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++
DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ Objective: To Learn Basic input, output, and procedural part of C++. C++ Object-orientated programming language
More informationDeclaring a 2D Array
Lecture 13 Declaring a 2D Array Model: type name[row_size ][ column_size] Example: int grades[10][20]; string students[10][20]; 2D Array data structure Say we have the following array: int grades[4][8];
More informationImplementation of Linked List into program
//Detail information of Linked List - KIDS Information Center #include #include using namespace std; struct node //node creation int info; node *link; //data field //link field ; node
More informationSorting Algorithms. Selection Sort Algorithm
Sorting Algorithms 015-016 Kirkuk Common problem: sort a list of values, starting from lowest to highest. List of exam scores, Words of dictionary in alphabetical order, Students names listed alphabetically,
More informationUnit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?
1 What is an array? Explain with Example. What are the advantages of using an array? An array is a fixed-size sequenced collection of elements of the same data type. An array is derived data type. The
More informationAPS105. Collecting Elements 10/20/2013. Declaring an Array in C. How to collect elements of the same type? Arrays. General form: Example:
Collecting Elements How to collect elements of the same type? Eg:., marks on assignments: APS105 Arrays Textbook Chapters 6.1-6.3 Assn# 1 2 3 4 5 6 Mark 87 89 77 96 87 79 Eg: a solution in math: x 1, x
More informationF.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C
F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1 (a) List any four relational operators.
More informationObject Oriented Programming
Object Oriented Programming in C++ CHAPTER 01 Introduction to OOP & C++ Difference between Procedure Oriented and Object Oriented Programming Procedure Oriented Programming Object Oriented Programming
More informationGovernment Polytechnic Muzaffarpur.
Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking
More informationArrays in C++ Instructor: Andy Abreu
Arrays in C++ Instructor: Andy Abreu Reason behind the idea When we are programming, often we have to process a large amount of information. We can do so by creating a lot of variables to keep track of
More informationKapi ap l S e S hgal P T C p t u er. r S. c S ienc n e A n A k n leshw h ar ar Guj u arat C C h - 8
Chapter 8 Introduction C++ Memory Map Free Stores Declaration and Initialization of pointers Dynamic allocation operators Pointers and Arrays Pointers and Const Pointers and Function Pointer and Structures
More informationQ1 (15) Q2 (15) Q3 (15) Q4 (15) Total (60)
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Date:.FN / AN Time: 2 hrs Full marks: 60 No. of students: 643 Spring Mid Semester Exams, 2011 Dept: Comp. Sc & Engg. Sub No: CS11001 B.Tech 1 st Year (Core) Sub
More informationSubject: Fundamental of Computer Programming 2068
Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find
More informationDeveloped By Strawberry
Experiment No. 3 PART A (PART A: TO BE REFFERED BY STUDENTS) A.1 Aim: To study below concepts of classes and objects 1. Array of Objects 2. Objects as a function argument 3. Static Members P1: Define a
More informationADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1
NAGERCOIL COMPUTER SCIENCE Grade: IX C++ PROGRAMMING 1 C++ 1. Object Oriented Programming OOP is Object Oriented Programming. It was developed to overcome the flaws of the procedural approach to programming.
More informationThe Queues. Front. Rear. Front. Rear. Rear = 0 Front = 0. Fig Queue is empty. Fig push(10) Rear = 1 Front = 0. Fig. 4.3.
4 The Queues A queue is logically a first in first out (FIFO or first come first serve) linear data structure. The concept of queue can be understood by our real life problems. For example a customer come
More information4. SEARCHING AND SORTING LINEAR SEARCH
4. SEARCHING AND SORTING SEARCHING Searching and sorting are fundamental operations in computer science. Searching refers to the operation of finding the location of a given item in a collection of items.
More informationBE III Semester ISE Page 1 of 1
Scheme of Valuation Date : 29-09-2015 Max Marks : 50 Marks Subject & Code: Object Oriented Programming with C++ (10CS36) Semester & Section: III A & B Name of Faculty: Prof.Sandesh & Mrs.Saritha Time :
More informationCONSTRUCTORS AND DESTRUCTORS
UNIT-II CONSTRUCTORS AND DESTRUCTORS Contents: Constructors Default constructors Parameterized constructors Constructor with dynamic allocation Copy constructor Destructors Operator overloading Overloading
More informationKapil Sehgal PGT Computer. Science Ankleshwar Gujarat
Classes Chapter 4 Classes and Objects Data Hiding and Encapsulation Function in a Class Using Objects Static Class members Classes Class represents a group of Similar objects A class is a way to bind the
More information