Programming in C++ (Educational Support)

Size: px
Start display at page:

Download "Programming in C++ (Educational Support)"

Transcription

1 Programming in C++ (Educational Support)

2 1. WRITE A PROGRAM TO TRAVERSING OF AN ARRAY. #include <iostream.h> # include <conio.h> void main () int a [10], lb = 1, ub, k, I; cout<< ENTER THE SIZE OF AN ARRAY: : ; cin>>ub; cout<< ENTER THE ELEMENTS OF AN ARRAY: ; for(lb=1;lb<=ub;lb++) cin>>a[lb]; cout<< TRAVERSED ELEMENTS ARE: ; for lb=1;lb<=ub;lb++) cout<<a[lb]<< \n ; getche(); OUTPUT ENTER THE SIZE OF AN ARRAY:5 ENTER THE ELEMENTS OF AN ARRAY: TRAVERSEED ELEMENTS ARE:

3 2. WRITE A PROGRAM TO INSERT AN ELEMENT IN AN ARRAY. void main() int la[20],i,j,k,n,item; cout<< ENTER THE SIZE OF AN ARRAY: ; cin>>n; cout<< ENTER THE ELEMENTS OF AN ARRAY: : for(i=1;i<=n;i++) cin>>la[i]; cout<< ENTER THE LOCATION WHERWW YOU WANT TO INSERT THE ELEMENTS: ; cin>>k; for(i=n;i>=k;i--) la[i+1]=la[i]; cout<< ENTER THE ELEMENTS TO BE INSERTED: ; cin>>item; la[k]=item; cout<< ARRAY AFTER INSERTION IS : ; for(i=1;i<=n+1;i++) cout<< \n <<la[i]; getche(); OUTPUT ENTER THE SIZE OF AN ARRAY:6 ENTER THE ELEMENTS OF AN ARRAY: ENTER THE LOCATION WHERE YOU WANT TO INSERT THE ELEMENT:3 ENTER THE ELEMEMNT TO BE INSERTED:15 ARRAY AFTER INSERTION IS :

4 3. WRITE A PROGRAM TO READ RADIUS OF A CIRCLE, CACULATE AREA AND PERIMETER AND DISPLAY THEM. int main() double radius,area,perimeter; cout<< ENTER RADIUS OF THE CIRCLE: : ; cin>>radius; perimeter=2* *radius; ares= *radius*radius; cout<< THE AREA OF THE CIRCLE IS: ; cout>>area; cout<< \n THE PERIMETER OF THE CIRCLE IS: ; cout<<perimeter; return 0 ; ENTER RADIUS OF THE CIRCLE:7.5 THE AREA OF THE CIRCLE IS : THE PERIMETER OF THE CIRCLE IS:

5 4. WRITE A PROGRAM TO WRITE THE EQUIVALENT OF A FOUR FUNCTION CALCULATOR. int main() char ch; float a,b,result; cout<< Enter two Numbers: ; cin>>a>>b; cout<< \n << Enter The Operatot(+,-,*,/) ): ; cin>>ch; cout<< \n ; if(ch== + ) result=a+b; else if (ch== - ) result=a-b; else if (ch== * ) result=a*b; else if (ch== / ) result=a/b; else cout<< \n <<Wrong Operatot! << \n ; goto lb; cout<< \n <<The Calculated Result Is : < << \n <<Result<< \n ; lb: return 0; Output Enter Two Numbers:9 3 Enter The Operatot (+,-,*,/):/ The Calculated Result Is :3

6 5. WRITE A PROGRAM TO INPUT NUMBER OF WEEK S DAY. int main () int d_o_w; cout<< Enter Number Of Week s Day(1-7): ; cin>> d_o_w ; switch(d_o_w ) case1:cout<< \nsunady ; break; case2:cout<< \nmonday ; break; case3:cout<< \ntuesday ; break; case4:cout<< \n Wednesday ; break; case5:cout<< \n Thursday ; break; case6:cout<< \n Friday ; break; case7:cout<< \n Saturday ; break; default:cout<< \Wrong Number Of Day! ; return 0; Output Enter Number Of Week s day (1-7):4 Wednesday

7 6. WRITE A PROGRAM USING FOR LOOP TO PRINT NUMBERS FROM 1 TO 10. int main () int i; for(i=1<=10;++i) cout<< \n <<I; return 0; Output:

8 7. WRITE A PROGRAM TO DELETE AN ELEMENT IN AN ARRAY. void main() int la[20],i,j,k,n,item; cout<< Enter The Size Of An Array: ; cin>>n; cout<< Enter The Element Of An Array: ; for(i=1;i<=n;i++) cin>>la[i]; cout<< Enter The Location Where You Want To Delete: ; cin>>k; i=n; for(j=k;j<=i;j++) la[j]=la[j+1]; cout<< Array After Deletion: ; for(i=1;i<-n;i++) cout<< \n <<la[i]; getcge(); Output: Enter The Size Of An Array:4 Enter The Elements Of An Array: Enter The Location Where You Want To Delete:2 Array After Deletion:

9 8. WRITE A PROGRAM TO CALCULATE THE FACTORIAL OF AN INTEGER. int main () int I, num, fact=1; cout<< \n Enter Integer: ; cin>>num; i=num; while(num) fact*=num; --num; cout<< The Factorial of <<i << is <<fact<< \n ; return 0; Enter Integer:5 The Factorial of 5 is 120

10 9. WRITE A PROGRAM TO READ A STRING AND PRINT ITS LENGTH. #include<string.h> void main () char astr[51]; int length; cout<< \n Enter a string\n ; gets(astr); length=strlen(astr); puts(astr); cout<< \n the length of the is: <<length< << \n ; Output Enter a string Computers Computers The Length of the string is :9

11 10. WRITE A PROGRAM TO COUNT NUMBER OF CHARACTERS ENTERED. Void main() int chcount=0; const char ent = \n ; char ch; cout<< Enter character\n ; cin.get(ch); while(ch!=ent) chcount++; cout.put(ch); cin.get(ch); cout<< \n The number of characters= << <chcount<< \n ; Output: Enter character Computer Programming Computer Programming The Number Of Characters=20

12 11. WRITE A PROGRAM TO FIND WHETHER TWO STRINGS CONTAIN EQUAL NUMBER OF CHARACTERS. #include<string.h> Void main () Char string1[50],string2[50]; cout<< Enter strings\n ; cin.getline(string1,50); cin.getline(string2,50); if (strlen(string1)==strlen(string2) ) out<< \n Both strings contain equal num << of characters << \n ; else cout<< \n Both strings contain dofferent mber number <<of characters << \n ; Output Enter strings Yohaan Neelam Bothe strings contain equal number of characters.

13 12. WRITE A PROGRAM TO READ MARKS OF 5 STUDENTS AND STORE THEM UNDER AN ARRAY. int main () float marks [5]; for(int i=0;i<5;++i) cout<< Enter the marks of student <<i+ +1<< : ; cin>>marks[i]; cout<< \n ; for(i=0;i<5;++i) cout<< Marks[ <<i<< ]= <<Marks[i]<< \ \n ; return 0; Output: Enter the marks of student1: 88 Enter the marks of student2: 67 Enter the marks of student3: 89 Enter the marks of student4: 56 Enter the marks of student5: 78 Marks[0]=88 Marks[1]=67 Marks[2]=89 Marks[3]=56 Marks[4]=78

14 13. WRITE A PROGRAM TO IMPLEMENT LINEAR SEARCH. #include<iomanip.h> Void main() int a[20],i,n,item,loc; int lsearch (int a[], int n, int,item); cout<< Enter number of element (<=20 ). ); cin>>n; for(i=0;i<n;i++) cout<< Enter element a[i]; cin>>a[i]; cout<< Enter item to be Search= ; cin item; oc=lsearch(a,n,item) if (loc==-1) out<< item does not exist in array ; else gout<< item <<item<< it exist at index= <<loc; getch(); int lsearch (int a[],intn,int item) int loc=-1,i=0; while(i<n&&a [i]!=item) I=i+1; if(a[i]==item) loc=i; return (loc); Output: Enter number of elements(<=20).4 Enter element a[0].6 Enter element a[1].7 Enter element a[0].9 Enter element a[0].4 Enter item to be Search=7 Item 7 exist at index=1

15 14. WRITE A PROGRAM TO IMPLEMENT BINARY SEARCH ] #include<iomanip.h> Void main() int a[20],i,n,loc,item; clrscr(0; int bsearch(int a[],int n, int item) cout<< enter no. of sorted element= ; cin>>n; for(i=0;i<n;i++) cout<< enter element a[ <<i<< ]= ; cin>>a[i]; cout<< enter item to search= ; cin>>item; loc= bsearch (a,n,item); if(loc==-1) cout<< item does not exist in array ; else cout<< itel it <<item<< it exist at index= = <<loc; getch(); int bsearch (int a[],int n, int item) int loc=-1, beg=0, end=n-1,mid; while (beg<=end) mid=(beg+and)/2; if(item==a[mid]) loc=mid; break; else if (item>a [mid]) beg=mid-1; return (loc); Output: Enter no. of sorted element=5 Enter element a[i]=7 Enter element a[i]=9 Enter element a[i]=11 Enter element a[i]=15 Enter element a[i]=21 Enter item to be search=11 Item 11 exist at index=2

16 15. WRITE A PROGRAM TO COPT A STRING TO ANOTHER. #include<string.h> Void main () char a[80],n80]; cout<< enter the string.. ; cin.get(a,80); strcpy(n,a); cout<< \n Copied String= <<n; getsc(); Output Enter the string..milennium Copied string=millennium

17 16. WRITE A PROGRAM TO REPLACE ANY OCCURRENCE OF WORD IS. #include<conio,h> #include<string.h> void main () clrscr (); char a[80]; int n, loc; cout<< enter a string= ; cin.getline (a,80); n=strlen(a); cout<< String to add : ; for (int i=0;a[i]!=0 \0 ;i++) If (a[i]== I &&a[i+1]= is &&(a[i+2]== (a[i+2]== 10 ) &&(a[i-1]== (a[i-1]== 10 )(a[0]== I )) loc=i; cout<<a[i]; getch(); Output: Where is my book. Where is my book.

18 17. WRITE A PROGRAM TO SORT THE NUMERIC DATA BY USING BUBBLE SORT. Void main () Int la[10],i,n,j,temp; cout<< Enter the sie of array: ; cin>>n; cout<< Enter the elements: ; for (i=0;i<n;i++) cin>>la[i]; for (j=0;k=-1;j++) if (la[j]>la[j+1]) temp=la[j] la[j]== la[j+1]; la[j+1]=temp; cout<< Array after sorting is: ; for (i=0;i<n;i++) cout<< \n <<la[i]; getch(); Output Enter the size oa array:3 Enter the elements:4 2 7 Array after sorting is:2 4 7

Downloaded from

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 information

Chapter4: Data Structures. Data: It is a collection of raw facts that has implicit meaning.

Chapter4: 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 information

CHAPTER 9 FLOW OF CONTROL

CHAPTER 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 information

CSE202- Lec#6. (Operations on CSE202 C++ Programming

CSE202- 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 information

An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store

An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store either all integers, all floating point numbers, all characters,

More information

CHAPTER : 9 FLOW OF CONTROL

CHAPTER : 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 information

Downloaded from

Downloaded 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 information

CSE101-lec#19. Array searching and sorting techniques. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming

CSE101-lec#19. Array searching and sorting techniques. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming CSE101-lec#19 Array searching and sorting techniques Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Introduction Linear search Binary search Bubble sort Introduction The process of finding

More information

Arrays. Elementary Data Representation Different Data Structure Operation on Data Structure Arrays

Arrays. 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 information

VOLUME II CHAPTER 9 INTRODUCTION TO C++ HANDS ON PRACTICE PROGRAMS

VOLUME 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

Sample Paper - II Subject Computer Science

Sample 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 information

DELHI PUBLIC SCHOOL TAPI

DELHI 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 information

1. 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.

1. 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 information

ASSIGNMENT CLASS-11 COMPUTER SCIENCE [C++]

ASSIGNMENT CLASS-11 COMPUTER SCIENCE [C++] ASSIGNMENT-1 2016-17 CLASS-11 COMPUTER SCIENCE [C++] 1 Consider the following C++ snippet: int x = 25000; int y = 2*x; cout

More information

C++ Final Exam 2017/2018

C++ Final Exam 2017/2018 1) All of the following are examples of integral data types EXCEPT. o A Double o B Char o C Short o D Int 2) After the execution of the following code, what will be the value of numb if the input value

More information

BRAIN INTERNATIONAL SCHOOL. Term-I Class XI Sub: Computer Science Revision Worksheet

BRAIN 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 information

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition) Structures Programming in C++ Sequential Branching Repeating Loops (Repetition) 2 1 Loops Repetition is referred to the ability of repeating a statement or a set of statements as many times this is necessary.

More information

Unit 2: Data Structures

Unit 2: Data Structures Unit 2: Data Structures 2.1: Arrays ARRAYS Introduction to data structure, Arrays, One Dimensional Array, Basic operations on 1-D array: traversal, Searching- linear, binary search, insertion, deletion,

More information

Sample 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 information

Functions. Introduction :

Functions. 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 information

Control Structure and Loop Statements

Control 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 information

Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon

Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon Data Structures &Al Algorithms Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon What is Data Structure Data Structure is a logical relationship existing between individual elements

More information

CHAPTER 4 FUNCTIONS. 4.1 Introduction

CHAPTER 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 information

ARRAY FUNCTIONS (1D ARRAY)

ARRAY FUNCTIONS (1D ARRAY) ARRAY FUNCTIONS (1D ARRAY) EACH QUESTIONS CARRY 2 OR 3 MARKS Q.1 Write a function void ChangeOver(int P[ ], int N) in C++, which re-positions all the elements of the array by shifting each of them to the

More information

Sample Paper Class XI Subject Computer Sience UNIT TEST II

Sample 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 information

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each.

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each. I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK 70. a) What is the difference between Hardware and Software? Give one example for each. b) Give two differences between primary and secondary memory.

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan Institute of Engineering & Technology for Diploma Studies 1. Explain Call by Value vs. Call by Reference Or Write a program to interchange (swap) value of two variables. Call By Value In call by value pass value, when we call the function. And copy this value

More information

1. Answer the following : a) What do you mean by Open Source Software. Give an example. (2)

1. Answer the following : a) What do you mean by Open Source Software. Give an example. (2) THE AIR FORCE SCHOOL Class XI First Terminal Examination 2017-18 Computer Science (083) Time: 3 hrs. M. Marks : 70 General Instructions : (i) All the questions are compulsory. (ii) Programming Language

More information

Lecture 4. 1 Statements: 2 Getting Started with C++: LESSON FOUR

Lecture 4. 1 Statements: 2 Getting Started with C++: LESSON FOUR 1 Statements: A statement in a computer carries out some action. There are three types of statements used in C++; they are expression statement, compound statement and control statement. Expression statement

More information

LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE

LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE Department of Software The University of Babylon LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE By Dr. Samaher Hussein Ali Collage of Information Technology, University of Babylon, Iraq Samaher_hussein@yahoo.com

More information

KENDRIYA VIDYALAYA PANGODE MONTHLY TEST I JUNE 2015 CLASS XII COMPUTER SCIENCE Time allowed: 1 1/2 Hours Max. Marks: 50

KENDRIYA VIDYALAYA PANGODE MONTHLY TEST I JUNE 2015 CLASS XII COMPUTER SCIENCE Time allowed: 1 1/2 Hours Max. Marks: 50 KENDRIYA VIDYALAYA PANGODE MONTHLY TEST I JUNE 2015 CLASS XII COMPUTER SCIENCE Time allowed: 1 1/2 Hours Max. Marks: 50 General Instructions: 1. All questions are compulsory. 2. Marks for each question

More information

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine

More information

Test Paper 1 Programming Language 1(a) What is a variable and value of a variable? A variable is an identifier and declared in a program which hold a value defined by its type e.g. integer, character etc.

More information

CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Chapter 6: One Dimensional Array

CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Chapter 6: One Dimensional Array Lesson Outcomes At the end of this chapter, student should be able to: Define array Understand requirement of array Know how to access elements of an array Write program using array Know how to pass array

More information

16. What is the significance of the break statement in a switch block?

16. What is the significance of the break statement in a switch block? Section A : Question carrying 1 Mark 01. How is data different from information? 02. Arrange the following in descending order :- Nibble, KB, Bit, GB,TB,Byte,MB 03. What is the significance of task bar

More information

Examination for the Second Term - Academic Year H Mid-Term. Name of student: ID: Sr. No.

Examination for the Second Term - Academic Year H Mid-Term. Name of student: ID: Sr. No. Kingdom of Saudi Arabia Ministry of Higher Education Course Code: ` 011-COMP Course Name: Programming language-1 Deanship of Preparatory Year Jazan University Total Marks: 20 Duration: 60 min Group: Examination

More information

KENDRIYA VIDYALYA CLRI COMPUTER SCIENCE XII WORKSHEET ON OUTPUT QUESTIONS

KENDRIYA VIDYALYA CLRI COMPUTER SCIENCE XII WORKSHEET ON OUTPUT QUESTIONS KENDRIYA VIDYALYA CLRI COMPUTER SCIENCE XII WORKSHEET ON OUTPUT QUESTIONS 1. What will be the output of following: void main ( ) int val = 10; cout

More information

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called.

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called. Chapter-12 FUNCTIONS Introduction A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called. Types of functions There are two types

More information

DC104 DATA STRUCTURE JUNE Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

DC104 DATA STRUCTURE JUNE Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? The heterogeneous linked list contains different data types in its nodes and we need a link

More information

Subject: Fundamental of Computer Programming 2068

Subject: 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 information

Q2: Write an algorithm to merge two sorted arrays into a third array? (10 Marks) Ans Q4:

Q2: 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 information

List 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. 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 information

UNIT-4 Statements:- Null Statement:- Compound Statement :- Statement Flow Control:- Sequence Construct:- Selection Construct

UNIT-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 information

Looping statement While loop

Looping 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 information

Purpose of Database Systems View of Data Database Languages Relational Databases Database Design Object based and semistructured Data Storage and

Purpose of Database Systems View of Data Database Languages Relational Databases Database Design Object based and semistructured Data Storage and Introduction (DBMS) Purpose of Database Systems View of Data Database Languages Relational Databases Database Design Object based and semistructured Data Storage and Querying Transaction Management Database

More information

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify

More information

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++

CHRIST 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 information

Data Structures. Chapter 04. 3/10/2016 Md. Golam Moazzam, Dept. of CSE, JU

Data Structures. Chapter 04. 3/10/2016 Md. Golam Moazzam, Dept. of CSE, JU Data Structures Chapter 04 1 Linear Array A linear array is a list of finite number N of homogeneous data elements such that: The elements of the array are referenced respectively by an index set consisting

More information

Downloaded from

Downloaded from Function: A function is a named unit of a group of statements that can be invoked from other parts of the program. The advantages of using functions are: Functions enable us to break a program down into

More information

LAB 4.1 Relational Operators and the if Statement

LAB 4.1 Relational Operators and the if Statement LAB 4.1 Relational Operators and the if Statement // This program tests whether or not an initialized value of num2 // is equal to a value of num1 input by the user. int main( ) int num1, // num1 is not

More information

COMPUTER SCIENCE (083)

COMPUTER SCIENCE (083) Roll No. Code : 112012-083 Please check that this question paper contains 7 questions and 8 printed pages. CLASS-XI COMPUTER SCIENCE (083) Time Allowed : 3 Hrs. Maximum Marks : 70 General Instructions

More information

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer:

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer: Chapter-11 POINTERS Introduction: Pointers are a powerful concept in C++ and have the following advantages. i. It is possible to write efficient programs. ii. Memory is utilized properly. iii. Dynamically

More information

CLASS-XI COMPUTER SCIENCE

CLASS-XI COMPUTER SCIENCE Roll No. Code : 112014-083-A Please check that this question paper contains 7 questions and 8 printed pages. CLASS-XI COMPUTER SCIENCE Time Allowed : 3 Hrs. Maximum Marks : 70 General Instructions : All

More information

m) sin() n) endl o) getch() p) cout

m) sin() n) endl o) getch() p) cout SAMPLE PAPER 1. a) Name the header file for the following built-in functions: a) log() b) exp() c) getch() d) isalnum() e) fabs() f) isalpha() g) toupper() h) cos() i) random() j) gets() k) abs() l) tolower()

More information

Q 1. Attempt any TEN of the following:

Q 1. Attempt any TEN of the following: Subject Code: 17212 Model Answer Page No: 1 / 26 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

More information

AE52/AC52/AT52 C & Data Structures JUNE 2014

AE52/AC52/AT52 C & Data Structures JUNE 2014 Q.2 a. Write a program to add two numbers using a temporary variable. #include #include int main () int num1, num2; clrscr (); printf( \n Enter the first number : ); scanf ( %d, &num1);

More information

SBOA SCHOOL & JUNIOR COLLEGE, CHENNAI 101 COMPUTER SCIENCE CLASS: XI HALF YEARLY EXAMINATION MAX MARKS:70 CODE - A DURATION : 3 Hours

SBOA SCHOOL & JUNIOR COLLEGE, CHENNAI 101 COMPUTER SCIENCE CLASS: XI HALF YEARLY EXAMINATION MAX MARKS:70 CODE - A DURATION : 3 Hours SBOA SCHOOL & JUNIOR COLLEGE, CHENNAI 101 COMPUTER SCIENCE CLASS: XI HALF YEARLY EXAMINATION 2016 MAX MARKS:70 CODE - A DURATION : 3 Hours All questions are compulsory. Do not change the order of the questions

More information

Before we start - Announcements: There will be a LAB TONIGHT from 5:30 6:30 in CAMP 172. In compensation, no class on Friday, Jan. 31.

Before we start - Announcements: There will be a LAB TONIGHT from 5:30 6:30 in CAMP 172. In compensation, no class on Friday, Jan. 31. Before we start - Announcements: There will be a LAB TONIGHT from 5:30 6:30 in CAMP 172 The lab will be on pointers In compensation, no class on Friday, Jan. 31. 1 Consider the bubble function one more

More information

Chapter-14 STRUCTURES

Chapter-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 information

Arrays. Dr. Madhumita Sengupta. Assistant Professor IIIT Kalyani

Arrays. Dr. Madhumita Sengupta. Assistant Professor IIIT Kalyani Arrays Dr. Madhumita Sengupta Assistant Professor IIIT Kalyani INTRODUCTION An array is a collection of similar data s / data types. The s of the array are stored in consecutive memory locations and are

More information

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE

CAMBRIDGE 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 information

QUESTION BANK UNIT III

QUESTION 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 information

2. Distinguish between a unary, a binary and a ternary operator. Give examples of C++ operators for each one of them.

2. 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 information

COMPUTER SCIENCE (083)

COMPUTER SCIENCE (083) Roll No. Code : 112011-083-A Please check that this question paper contains 7 questions and 6 printed pages. CLASS-XI COMPUTER SCIENCE (083) Time Allowed : 3 Hrs. Maximum Marks : 70 General Instructions

More information

Important Questions 2010 Class-XII-Computer Science

Important 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 information

Data 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:

Data 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 information

Chapter : 5 Structure data types Arrays. <<reverse[i]<< \n ; getch(); } Output:

Chapter : 5 Structure data types Arrays. <<reverse[i]<< \n ; getch(); } Output: Chapter : 5 Structure data types Arrays Examples: 1.Arrays and basic manipulation on arrays: [Pg-128] int a[5], ctr = 0, sum; for(;ctra[ctr]; for(ctr=0, sum=0;ctr

More information

Aim :- To find shortest path (Using Dijkstra Algorithm in Networking).

Aim :- To find shortest path (Using Dijkstra Algorithm in Networking). Aim :- To find shortest path (Using Dijkstra Algorithm in Networking). #include #include class graph public: char a; char b; int e; ; class dijkstra public: int n,p,t,f; char c[10];

More information

LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE

LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE Department of Software The University of Babylon LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE By Collage of Information Technology, University of Babylon, Iraq Samaher_hussein@yahoo.com

More information

CMPE110, Sample questions

CMPE110, Sample questions CMPE110, Sample questions Number : Name :... Q1)Give the correct answer for following: 1. What is the value of x after the following statement? double x; x = 3.0 / 4.0 + 3 + 2 / 4 a. 5.75 b. 4.25 c. 1.75

More information

Arrays. Week 4. Assylbek Jumagaliyev

Arrays. Week 4. Assylbek Jumagaliyev Arrays Week 4 Assylbek Jumagaliyev a.jumagaliyev@iitu.kz Introduction Arrays Structures of related data items Static entity (same size throughout program) A few types Pointer-based arrays (C-like) Arrays

More information

EXP 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 <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 information

Downloaded S. from Kiran, PGT (CS) KV, Malleswaram STRUCTURES. Downloaded from

Downloaded 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 information

DE122/DC106 Object Oriented Programming with C++ DEC 2014

DE122/DC106 Object Oriented Programming with C++ DEC 2014 Q.2 a. Distinguish between Procedure-oriented programming and Object- Oriented Programming. Procedure-oriented Programming basically consists of writing a list of instructions for the computer to follow

More information

OOP THROUGH C++(R16) int *x; float *f; char *c;

OOP 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 information

Consider the following statements. string str1 = "ABCDEFGHIJKLM"; string str2; After the statement str2 = str1.substr(1,4); executes, the value of str2 is " ". Given the function prototype: float test(int,

More information

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1

ADARSH 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 information

OBJECTS. 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 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 information

Object Oriented Pragramming (22316)

Object Oriented Pragramming (22316) Chapter 1 Principles of Object Oriented Programming (14 Marks) Q1. Give Characteristics of object oriented programming? Or Give features of object oriented programming? Ans: 1. Emphasis (focus) is on data

More information

Darshan Institute of Engineering & Technology for Diploma Studies Unit 5

Darshan Institute of Engineering & Technology for Diploma Studies Unit 5 1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different data types grouped together under a single name. Structure is

More information

C++ is case sensitive language, meaning that the variable first_value, First_Value or FIRST_VALUE will be treated as different.

C++ 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 information

COMPUTER SCIENCE PRACTICAL GUIDE [ ENGLISH MEDIUM ]

COMPUTER 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 information

c++ Solutions eedsohag.epizy.com Ahmed Ali

c++ Solutions eedsohag.epizy.com Ahmed Ali c++ s Ahmed Ali int main(int argc, char *argv[]) int age; age=10; cout

More information

CSE202-Lec#4. CSE202 C++ Programming

CSE202-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 information

If the numbers are 5 and 2,

If the numbers are 5 and 2, Chapter : 4 Functions Examples 1. An example for functions.[pg-94] int fact(int num) int factorial = 1; for(inta=1;a

More information

Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013

Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013 Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013 One Dimensional Q1: Write a program that declares two arrays of integers and fills them from the user. Then exchanges their values and display the

More information

The Hyderabad Public School, Begumpet, Hyderabad, A.P

The Hyderabad Public School, Begumpet, Hyderabad, A.P The Hyderabad Public School, Begumpet, Hyderabad, A.P. 500 016 2012-13 Department of Computer Science Class 8 Worksheet 3 1) How many times will the following statement execute? ( ) int a=5; while(a>6)

More information

(4) Find the syntax error(s), if any, in the following program: #include main() int x[5],*y,z[5]; for(i=0;i<5;i++) x[i]=i; z[i]=i+3; y=z; x=y; (5) Rew

(4) Find the syntax error(s), if any, in the following program: #include main() int x[5],*y,z[5]; for(i=0;i<5;i++) x[i]=i; z[i]=i+3; y=z; x=y; (5) Rew (1)Rewrite the following program after removing the syntactical error(s), if any Underline each correction, struct TV char Manu_name[20]; char Tv_Type; int Price = 17000; New Tv; gets(manu_name); gets(tv_type);

More information

Search Algorithms. Linear Search Binary Search

Search Algorithms. Linear Search Binary Search Search Algorithms Linear Search Binary Search Searching The process used to find the location of a target among a list of objects Searching an array finds the index of first element in an array containing

More information

CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad

CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad Outline 1. C++ Iterative Constructs 2. The for Repetition Structure 3. Examples Using the for Structure 4. The while Repetition Structure

More information

خ ث ح 13:10 14:00 خ ث ح 51:51 16:11 ر ن 09:41 11:11 ر ن

خ ث ح 13:10 14:00 خ ث ح 51:51 16:11 ر ن 09:41 11:11 ر ن Philadelphia University Faculty of Engineering Department of Computer Engineering Programming Language (630263) Date:- 07/02/2015 Allowed time:- 2 Hours Final Exam Student Name: -... ID: - Instructor:

More information

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Ch - 7. Data File Handling

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Ch - 7. Data File Handling Introduction Data File Handling The fstream.h Header file Data Files Opening and Closing File Steps to process a File in your Program Changing the behavior of Stream Sequential I/O With Files Detecting

More information

LOGO BASIC ELEMENTS OF A COMPUTER PROGRAM

LOGO BASIC ELEMENTS OF A COMPUTER PROGRAM LOGO BASIC ELEMENTS OF A COMPUTER PROGRAM Contents 1. Statements 2. C++ Program Structure 3. Programming process 4. Control Structure STATEMENTS ASSIGNMENT STATEMENTS Assignment statement Assigns a value

More information

Introduction To Computer Programming C++ Mr. Clausen Program C11A, C11B

Introduction To Computer Programming C++ Mr. Clausen Program C11A, C11B Introduction To Computer Programming C++ Mr. Clausen Program C11A, C11B Program 11A: Cone Heads with Functions 30 points Write a program that calculates the volume of a right circular cone using functions.

More information

b) #include<iostream.h> void main() { int a, b; cout<<"input two integer values? "; cin>>a>>b; double avg=(a+b)/2.0; cout<<"average="<<avg<<endl; }

b) #include<iostream.h> void main() { int a, b; cout<<input two integer values? ; cin>>a>>b; double avg=(a+b)/2.0; cout<<average=<<avg<<endl; } SAMPLEPAPER-2016 (Class 11) 1a)Name the header file(s) that shall be needed for successful compilation of the following C++ code. void main( ) char Name[20]; gets(name); int n=1+random(5); for(int k=0;k

More information

F.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 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 information

Boolean Data-Type. Boolean Data Type (false, true) i.e. 3/6/2018. The type bool is also described as being an integer: bool bflag; bflag = true;

Boolean Data-Type. Boolean Data Type (false, true) i.e. 3/6/2018. The type bool is also described as being an integer: bool bflag; bflag = true; Programming in C++ If Statements If the sun is shining Choice Statements if (the sun is shining) go to the beach; True Beach False Class go to class; End If 2 1 Boolean Data Type (false, ) i.e. bool bflag;

More information

Variable Definitions and Scope

Variable Definitions and Scope Variable Definitions and Scope The scope of a variable is the part of the program where the variable may be used. For a variable defined inside a function, its scope is the function, from the point of

More information

C C++ C++! "# C++ ++

C C++ C++! # C++ ++ C++ C+ ++ C++ C++.. C++. Brace. " ". /* */ // 31.. Case Sensitive (if, char, while, ). C. char a ; float pi=3.14; : : = ; ; : : . char Character or small integer 1byte short int Short Integer 2bytes int

More information

C++ PROGRAMMING SKILLS Part 2 Programming Structures

C++ PROGRAMMING SKILLS Part 2 Programming Structures C++ PROGRAMMING SKILLS Part 2 Programming Structures If structure While structure Do While structure Comments, Increment & Decrement operators For statement Break & Continue statements Switch structure

More information