Introduction to Algorithms and Programming (COMP151)
|
|
- Kathryn McCormick
- 5 years ago
- Views:
Transcription
1 Introduction to Algorithms and Programming (COMP151) A Student's Manual for Practice Exercises Dr. Mohamed Aissa m.issa@unizwa.edu.om 11i13 Summer 2014
2 Practice Exercises #1 Introduction Page 2 Practice Exercises #1 Introduction to C++ STUDENT LEARNING OUTCOMES: Upon completion of these exercises, a successful student will be able to: state the followed steps to execute C++ program, understand header files, differentiate between local and global variables, use comment lines, declare variables Questions 1. Complete the following table to show the difference between an interpreter and a compiler: Compiler Interpreter 1. Fill the following table using numbers from 1 to 4 to indicate the order of executing of C++ program. Linking Compiling Execution Program Editing
3 Practice Exercises #1 Introduction Page 3 3. Write in the following table the operation yielding to each mentioned file. Operation Source Code Object file Executed Program 4. What header file must you #include with your source file to use cout and cin? 5. What header file must you #include with your program to use setw? 6. What is the difference between local and global variables? 7. What is the scope of local and global variables?
4 Practice Exercises #1 Introduction Page 4 8. What are the symbols used for comment lines? 9. Why do we use comment lines? 10. Some lines can begin with # in a C++ program. What is the effect of this symbol on such lines? 10. Explain the role of the following line in a C++ program. #include<iostream> 11. Explain the role of the following line in a C++ program.
5 Practice Exercises #1 Introduction Page What are identifiers? 13. Are there any restrictions on variable names? 14. Give the definition of reserved keywords. 15. Explain the following line in a C++ program? int a(0);
6 Practice Exercises #2 Operators in C++ Page 6 Practice Exercises #2 Operators in C++ STUDENT LEARNING OUTCOMES: Upon completion of this assignment, a successful student will be able to use the following operators in C++ programs: arithmetic operators, assignment operator, compound assignment (or) Arithmetic assignment operators, increment and Decrement Operators, relational and equality operators, logical operators (!, &&, ), conditional operator (? : ) or Ternary Operator, explicit type casting operator, precedence of arithmetic operators Exercises 1. Fill the following table using different methods to write the expression: Classical Form First New Method Second New Method z=z+1 w=w-1
7 Practice Exercises #2 Operators in C++ Page 7 2. Fill in the following table: x=2, y=1, z=3 Expression Expression Precedence Output Data X+y*z X+(y*z) X + y*z - z%x X + y*z z/y 3. For each expression in the following table, write whether the result is True of False. Expression True (1) or False (0) (8 == 8) && (7!= 9) (9 > 3) (10 < 1) (6 == 2) && (12 == 13)!(3 == 7)
8 Practice Exercises #2 Operators in C++ Page 8 4. Evaluate the following expressions: v=8*15+10%6*7-9 w=(9*(16+9)%3)*8-15 x=90*10+29/5%2*3-6*2 y=15/3-7*8-6*4+10%3 5. Show the order of evaluation and find the final result for each of the following expression. x=6, y=3, z=8, w=1 a. M= x/(y+z*w-1)%(y+1+w) b. M=(x-3)/(y-2)*(w-z%3)
9 Practice Exercises #2 Operators in C++ Page 9 4. In the following program, we numerated each printed line. #include <iostream> main( ) int i=7; ( 1 ) cout<<"\n"<<i++; ( 2 ) cout<<"\n"<<i; ( 3 ) cout<<"\n"<<--i; ( 4 ) cout<<"\n"<<i; ( 5 ) cout<<"\n"<<i--; ( 6 ) cout<<"\n"<<i; return (0); a. What is the initial value of " i "? The initial value of " i " is.. b. Write the current printed value of " i " after the execution of each numerated line. Line Number Printed value of " i "
10 Practice Exercises #2 Chapter 3 Operators in C++ Page What are the outputs of the following program? #include<iostream> int main() int x,y; x=10; y=4; x=b; y=7; cout<<"x="<<x<<endl; cout<<"y="<<y; return(0); Output x= y= 6. What are the outputs of the following program? #include<iostream> int main() int x,y,z; x=10; y=4; z=15 x+=3; y*=5; Z/=3; cout<<"x="<<x<<endl; cout<<"y="<<y<<endl; cout<<"z="<<z<<endl; return(0); Output x= y=
11 Practice Exercises #2 Chapter 3 Operators in C++ Page Explain the following line in a C++ program. condition? result1 : result2 8. What are the outputs of the following line? 9==7+2? 4 : 3 7>9? a : b 9. What is the value of i in the following part of a C++ program? int i; float f = ; i=(int)f;
12 Practice Exercises #3 Chapter 4 Control Structures Page 12 Practice Exercises #3 Conditional Structures Related Chapter Chapter Title 4 Control Structures STUDENT LEARNING OUTCOMES: Upon completion of this computer lab, a successful student will be able to: draw a flowchart to calculate the value of a given function containing conditions, translate the flowchart into a C++ program, understand compilation errors and correct them. Questions 1. Suppose the following function: ( ) a. Complete the following flowchart to calculate ( ) b. Based on the flowchart, complete the following C++ program.
13 Practice Exercises #3 Chapter 4 Control Structures Page 13 START #include <iostream> int main( ) yes no int x; int f; cout <<"Input x "<<endl; cin>>x; f=0; if ( ) else ; ; cout << " x = "<<x<<endl; cout << " f="<<f<<endl; return (0); END
14 Practice Exercises #3 Chapter 4 Control Structures Page Suppose the following function: ( ) a. Complete the following flowchart to calculate ( ) b. Based on the flowchart, complete the following C++ program. START #include <iostream> int main() int f; int x; yes no cout <<"Input x "<<endl; cin>>x; f=0; if ( ) else ; ; END cout << " x = "<< <<endl; cout << " f="<< <<endl; return (0);
15 Practice Exercises #3 Chapter 4 Control Structures Page Suppose the following function: ( ) a. Draw the flowchart to calculate ( ) b. Based on the flowchart, write the C++ program.
16 Practice Exercises #3 Chapter 4 Control Structures Page Suppose the following function: ( ) c. Draw the flowchart to calculate ( ) d. Based on the flowchart, write the C++ program. START yes no yes no yes no END
17 Practice Exercises #3 Chapter 4 Control Structures Page Draw a flowchart to find the roots of the following second degree equation in the set of the real numbers: Flowchart ax 2 bx c 0, a, b, c, a 0,
18 Practice Exercises #3 Chapter 4 Control Structures Page 18 Based on this algorithm, write the corresponding C++program.
19 Practice Exercises #3 Chapter 4 Control Structures Page 19
20 Practice Exercises #4 Chapter 4 Control Structures Page 20 Practice Exercises #4 Looping Structures Related Chapter Chapter Title 4 Control Structures STUDENT LEARNING OUTCOMES: Upon completion of this computer lab, a successful student will be able to: draw a flowchart containing a loop, understand the different looping structures in C++, translate the flowchart into a C++ program and write three C++ programs using the three loop types, understand compilation errors and correct them. Questions 1. Draw a flowchart to calculate the following integer summation: ( ) 2. Based on this flowchart, write the C++ program using the three looping types (for, while, and do while).
21 Practice Exercises #4 Chapter 4 Control Structures Page 21 START // Summation of integer numbers included between 1 and n using for loop n s i s s + i i i + #include <iostream> int main() int sum= 0; int number=1, n; cout << " Input a positive integer number : "<<endl; cin>>n; for(number=1;number<= n;number++) yes i n sum=sum+number; n s END no cout << "\n Sum of numbers includeded between 1 and " <<n<<" = "<<sum<<endl<<endl; return (0); // indicate program ended successfully
22 Practice Exercises #4 Chapter 4 Control Structures Page 22 // Summation of integer numbers included between 1 and n using while loop // Summation of integer numbers included between 1 and n using do while Loop #include <iostream> int main() int sum= 0; int number=1, n; cout << " Input a positive integer number : "<<endl; cin>>n; while ( number <= n) sum += number; number++; cout << "\n Sum of numbers includeded between 1 and " <<n<<" = "<<sum<<endl<<endl; #include <iostream> int main() int sum= 0; int number=1, n; cout << " Input a positive integer number : " <<endl; cin>>n; do sum += number; number++; while(number<=n); return (0); cout << "\n Sum of numbers includeded between 1 and " <<n<<" = "<<sum<<endl<<endl; return (0);
23 Practice Exercises #5 Chapter 5 Arrays Page 23 Practice Exercises #5 One-Dimensional Arrays Related Chapter Chapter Title 5 Arrays STUDENT LEARNING OUTCOMES: Upon completion of this computer lab, a successful student will be able to: declare one-dimensional arrays, initialize a one-dimensional arrays, print the elements of one-dimensional arrays, detect syntax errors and correct them Reminder Initializing One-Dimensional Array in Declarations The initialization in declaration the one-dimensional array of yearly expenses, is done as follows: int e [12] = 3200, 2500, 2800, 3100, 4000, 4500, 5000, 3500, 2500, 4100, 6000, 5500; Here e[0] is initialized to 3200; e[1] is initialized to 2500, and so on. Observation We can omit the size of the array when we initialize it in a declaration: Float marks[ ] = 1.5, 9.10, 11, 12;
24 Practice Exercises #5 Chapter 5 Arrays Page 24 Example 1 Let's shows how to declare an array of five integers //How to declare an array and to fill it #include <iostream> int main() int A[5]=-1, 2, 9, -3, 10 ; int i; for (i = 0; i<5; i++) cout << "A[" << i << "]: "<< A[i] << "\n"; return(0); Program Output A[0]: -1 A[1]: 2 A[2]: 9 A[3]: -3 A[4]: 10 Press any key to continue
25 Practice Exercises #5 Chapter 5 Arrays Page 25 Example 2 Let's shows how to declare an array of five integers and fill each with a value /How to declare an array and to fill it #include <iostream> int main() int A[5]; int i; cout <<"\n Input the values of the array elements \n"<<endl; for ( i=0; i<5; i++) // 0-4 cout << "A[" << i << "]= "; cin >> A[i]; cout <<"\n Printing the array elements \n"; cout <<endl; for (i = 0; i<5; i++) cout << "A[" << i << "]= " << A[i] << "\n"; cout <<endl; return 0; Program Output Input the values of the array elements A[0]= 1 A[1]= 2 A[2]= 3 A[3]= 9 A[4]= 3 Printing the array elements A[0]= 1 A[1]= 2 A[2]= 3 A[3]= 9 A[4]= 3 Press any key to continue
26 Practice Exercises #5 Chapter 5 Arrays Page 26 Analysis: Line 6 declares an array called A, which holds five integer variables. Line 11 establishes a loop that counts from 0 through 4, which is the proper set of offsets for a five-element array. The user is prompted for a value, and that value is saved at the correct offset into the array. The first value is saved at A[0], the second at A[1], and so forth. The second for loop (line 19) prints each value to the screen. Questions 1. Fill in the following table with the values of the variable sum at the indicated iterations. Program i sum #include <iostream> int main() int myarray[5]=-1, 2, 9, -3, 10 ; int i; int sum=0; for (i = 0; i<5; i++) sum=sum+ myarray[i]; cout << sum << "\n"; return(0);
27 Practice Exercises #5 Chapter 5 Arrays Page Fill in the following table to fix the values of of "i" and "sum" at lines 1 and 2. #include <iostream> int main() int sum=0; int i=0; int myarray[5]=-1, 2, 9, -3, 10 ; 1. sum=sum+i; for (i = 0; i<5; i++) sum=sum+ myarray[i]; 2. cout << i<<" "<<sum << "\n"; return(0); Line Number Value of i Value of sum How many times the following loop will be executed and what is the value of the output sum? Program #include <iostream> int main() int a[3]=-1, 2, 3 ; int i; int sum=0; for (i = 0; i<3; i++) sum=sum+a[i]; cout << sum << "\n"; return 0; Maximum number of iterations: Value of Sum at the end of program execution:
28 Practice Exercises #5 Chapter 5 Arrays Page The following programs contain errors. Put the symbol "X" in the sentence containing errors, then rewrite this sentence correctly. Program with errors X Corrected sentences #include <iostream> Int main() Int a[5]=-1, 2, 3 ; int sum=0; while (i <7) sum=sum+a (i); cout << sum << "/n"; return(0); Program with errors X Corrected Sentences #include <iostream> int main() int a[3][2]=-1, 2, 3,1,0,2,2,5 ; int i; int sum=0; for (I = 0; i--) sum=sum+a[i]; cout << sum << "\n"; return 0
Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
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 information1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.
1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format
More informationUnit 3. Operators. School of Science and Technology INTRODUCTION
INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.
More informationProgramming for Engineers Iteration
Programming for Engineers Iteration ICEN 200 Spring 2018 Prof. Dola Saha 1 Data type conversions Grade average example,-./0 class average = 23450-67 893/0298 Grade and number of students can be integers
More informationo Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement
Last Time Let s all Repeat Together 10/3/05 CS150 Introduction to Computer Science 1 1 We covered o Counter and sentinel controlled loops o Formatting output Today we will o Type casting o Top-down, stepwise
More informationREPETITION CONTROL STRUCTURE LOGO
CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationAdd Subtract Multiply Divide
ARITHMETIC OPERATORS if AND if/else AND while LOOP Order of Operation (Precedence Part 1) Copyright 2014 Dan McElroy Add Subtract Multiply Divide + Add - Subtract * Multiply / Divide = gives the quotient
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College October 24, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Expressions and Operator Precedence
More informationLaboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++
Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ 0.1 Introduction This is a session to familiarize working with the Visual Studio development environment. It
More informationChapter 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 informationC++ Programming Lecture 7 Control Structure I (Repetition) Part I
C++ Programming Lecture 7 Control Structure I (Repetition) Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department while Repetition Structure I Repetition structure Programmer
More informationC++ Programming for Non-C Programmers. Supplement
C++ Programming for Non-C Programmers Supplement ii C++ Programming for Non-C Programmers C++ Programming for Non-C Programmers Published by itcourseware, 10333 E. Dry Creek Rd., Suite 150, Englewood,
More informationLAB 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 informationComputer Programming : C++
The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationC++ Programming for Non-C Programmers. Supplement
C++ Programming for Non-C Programmers Supplement C++ Programming for Non-C Programmers C++ Programming for Non-C Programmers Published by ITCourseware, 7245 S. Havana St, Suite 100, Centennial, CO 80112
More informationThe American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011
The American University in Cairo Department of Computer Science & Engineering CSCI 106-07&09 Dr. KHALIL Exam-I Fall 2011 Last Name :... ID:... First Name:... Form I Section No.: EXAMINATION INSTRUCTIONS
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationIn this chapter you will learn:
1 In this chapter you will learn: Essentials of counter-controlled repetition. Use for, while and do while to execute statements in program repeatedly. Use nested control statements in your program. 2
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine
More informationProgramming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3
Programming - 1 Computer Science Department 011COMP-3 لغة البرمجة 1 011 عال- 3 لطالب كلية الحاسب اآللي ونظم المعلومات 1 1.1 Machine Language A computer programming language which has binary instructions
More informationA Freshman C++ Programming Course
A Freshman C++ Programming Course Dr. Ali H. Al-Saedi Al-Mustansiria University, Baghdad, Iraq January 2, 2018 1 Number Systems and Base Conversions Before studying any programming languages, students
More informationChapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++
Repetition Contents 1 Repetition 1.1 Introduction 1.2 Three Types of Program Control Chapter 5 Introduction 1.3 Two Types of Repetition 1.4 Three Structures for Looping in C++ 1.5 The while Control Structure
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 informationBy the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program
1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize
More informationLoops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017
Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The
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 informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationSRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR
SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name
More informationIntroduction to C++ 2. A Simple C++ Program. A C++ program consists of: a set of data & function definitions, and the main function (or driver)
Introduction to C++ 1. General C++ is an Object oriented extension of C which was derived from B (BCPL) Developed by Bjarne Stroustrup (AT&T Bell Labs) in early 1980 s 2. A Simple C++ Program A C++ program
More informationLooping. Arizona State University 1
Looping CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 5 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationProgramming in C++ The manager of a company. Lecture Notes 6. Functions (Procedures) 4/24/2018. he he he. Does Does Does
The manager of a company Programming in C++ Lecture Notes 6 Functions (Procedures) Does Does Does he he he pay the bills? answer the phone? clean the office? 2 1 Division of Labor Our programs until now
More informationLab # 02. Basic Elements of C++ _ Part1
Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special
More informationThe Unix Environment for Programming (COMP433)
The Unix Environment for Programming (COMP433) Student's Practical Manual Dr. Mohamed Ben Laroussi Aissa m.issa@unizwa.edu.om Room 11 I- 13 Spring 2017 1 Textbook Topic # Topic Page 1 Introduction 2 3
More informationConcepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.
Concepts Review 1. An algorithm is a sequence of steps to solve a problem. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. 3. A flowchart is the graphical
More informationErrata for C++ and Algorithmic Thinking for the Complete Beginner
Errata for C++ and Algorithmic Thinking for the Complete Beginner 12 What it Hardware? The Central Processing Unit (CPU) This is the part of a computer that actually performs all the tasks defined in a
More informationM4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE
M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be
More informationWhy Is Repetition Needed?
Why Is Repetition Needed? Repetition allows efficient use of variables. It lets you process many values using a small number of variables. For example, to add five numbers: Inefficient way: Declare a variable
More informationChapter1 Overview of computers
1 Chapter1 Overview of computers 1. What is a computer? 2. Which is the earliest computing machine? 3. Who invented the pascaline? 4. What is Charles babbage known as? 5. What is the machine proposed by
More informationComputer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:
Computer Department Program: Computer Midterm Exam Date : 19/11/2016 Major: Information & communication technology 1 st Semester Time : 1 hr (10:00 11:00) Course: Introduction to Programming 2016/2017
More informationOther operators. Some times a simple comparison is not enough to determine if our criteria has been met.
Lecture 6 Other operators Some times a simple comparison is not enough to determine if our criteria has been met. For example: (and operation) If a person wants to login to bank account, the user name
More informationPOINTERS. Pointer is a memory variable which can store address of an object of specified data type. For example:
POINTERS Pointer is a memory variable which can store address of an object of specified data type For example: #include int x=5; int *a;//here a is a pointer to int which can store address of
More informationObject Oriented Programming Using C++ Mathematics & Computing IET, Katunayake
Assigning Values // Example 2.3(Mathematical operations in C++) float a; cout > a; cout
More informationCOMPUTER 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 informationTrue or False (14 Points)
Name Number True or False (14 Points) 1. (15 pts) Circle T for true and F for false: T F a) void functions can use the statement return; T F b) Arguments corresponding to value parameters can be variables.
More informationBasic Source Character Set for C++ Language:
Lecture 4 1. Programming in C++ Language: C++ was created by Bjarne Stroustrup, beginning in 1979. The development and refinement of C++ was a major effort, spanning the 1980s and most of the 1990s. Finally,
More informationComputer Engineering Department CMPE110 Midterm Sample Questions, 2017/ Fall
Computer Engineering Department CMPE110 Midterm Sample Questions, 2017/2018 - Fall Q1) Give the correct answer for following: 1. What is the value of x after the following statement? double x; x = 3.0
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 informationProgramming. C++ Basics
Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++
More informationObject-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering
Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering Lecture 3 Winter 2011/12 Oct 25 Visual C++: Problems and Solutions New section on web page (scroll down)
More informationOperators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur
Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators
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 informationTutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays
Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Outline 13.1 Test-Driving the Salary Survey Application 13.2 Introducing Arrays 13.3 Declaring and Initializing Arrays 13.4 Constructing
More informationWeek 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.
Week 2 Branching & Looping Gaddis: Chapters 4 & 5 CS 5301 Spring 2018 Jill Seaman 1 Relational Operators l relational operators (result is bool): == Equal to (do not use =)!= Not equal to > Greater than
More informationQ1 Q2 Q3 Q4 Q5 Total 1 * 7 1 * 5 20 * * Final marks Marks First Question
Page 1 of 6 Template no.: A Course Name: Computer Programming1 Course ID: Exam Duration: 2 Hours Exam Time: Exam Date: Final Exam 1'st Semester Student no. in the list: Exam pages: Student's Name: Student
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 information5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators
Chapter 5: 5.1 Looping The Increment and Decrement Operators The Increment and Decrement Operators The Increment and Decrement Operators ++ is the increment operator. It adds one to a variable. val++;
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationObjectives. In this chapter, you will:
Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about
More informationCS2141 Software Development using C/C++ C++ Basics
CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short
More informationName SECTION: 12:45 2:20. True or False (12 Points)
Name SECION: 12:45 2:20 rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables
More informationLecture 2:- Functions. Introduction
Lecture 2:- Functions Introduction A function groups a number of program statements into a unit and gives it a name. This unit can then be invoked from other parts of the program. The most important reason
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationC++ 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 informationB.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University
Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are
More informationChapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the
More informationCS242 COMPUTER PROGRAMMING
CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing
More informationUniversity of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.
University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Fifth week Control Structures A program is usually not limited to a linear sequence of instructions. During its process
More informationOperators in C. Staff Incharge: S.Sasirekha
Operators in C Staff Incharge: S.Sasirekha Operators An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C
More informationUnit 7. 'while' Loops
1 Unit 7 'while' Loops 2 Control Structures We need ways of making decisions in our program To repeat code until we want it to stop To only execute certain code if a condition is true To execute one segment
More informationScientific Computing
Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course
More informationWARM UP LESSONS BARE BASICS
WARM UP LESSONS BARE BASICS CONTENTS Common primitive data types for variables... 2 About standard input / output... 2 More on standard output in C standard... 3 Practice Exercise... 6 About Math Expressions
More informationIntroduction to Programming using C++
Introduction to Programming using C++ Lecture One: Getting Started Carl Gwilliam gwilliam@hep.ph.liv.ac.uk http://hep.ph.liv.ac.uk/~gwilliam/cppcourse Course Prerequisites What you should already know
More informationLecture 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 informationComputers Programming Course 6. Iulian Năstac
Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap
More informationClass 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)
Class 2: Variables and Memory Variables A variable is a value that is stored in memory It can be numeric or a character C++ needs to be told what type it is before it can store it in memory It also needs
More informationAssignment: 1. (Unit-1 Flowchart and Algorithm)
Assignment: 1 (Unit-1 Flowchart and Algorithm) 1. Explain: Flowchart with its symbols. 2. Explain: Types of flowchart with example. 3. Explain: Algorithm with example. 4. Draw a flowchart to find the area
More information1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?
Exercises with solutions. 1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl? #include b) What using statement do you always put at the top of
More informationObject Oriented Design
Object Oriented Design Chapter 6 Example Activity Diagram 1 Outline Chapter 6 Topics 6.6 C++ Standard Library Header Files 6.14 Inline Functions 6.16 Default Arguments 6.17 Unary Scope Resolution Operator
More informationUEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter
UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter What you will learn from Lab 7 In this laboratory, you will understand how to use typical function prototype with
More informationCPE 112 Spring 2015 Exam III (100 pts) April 8, True or False (12 Points)
Name rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables retain their value
More informationc++ keywords: ( all lowercase ) Note: cin and cout are NOT keywords.
Chapter 1 File Extensions: Source code (cpp), Object code (obj), and Executable code (exe). Preprocessor processes directives and produces modified source Compiler takes modified source and produces object
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and
More informationComputer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons
Computer Programming Basic Control Flow - Loops Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To learn about the three types of loops: while for do To avoid infinite
More informationFundamentals of Programming CS-110. Lecture 2
Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout
More informationChapter 2 - Control Structures
Chapter 2 - Control Structures 1 2.11 Assignment Operators 2.12 Increment and Decrement Operators 2.13 Essentials of Counter-Controlled Repetition 2.1 for Repetition Structure 2.15 Examples Using the for
More informationEngineering Problem Solving with C++, Etter/Ingber
Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs C++, Second Edition, J. Ingber 1 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input
More informationStructured Programming. Flowchart Symbols. Structured Programming. Selection. Sequence. Control Structures ELEC 330 1
ELEC 330 1 Structured Programming Control Structures ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne Algorithm Development Conditional Expressions Selection Statements Loops 206_C3
More informationC++ for Python Programmers
C++ for Python Programmers Adapted from a document by Rich Enbody & Bill Punch of Michigan State University Purpose of this document This document is a brief introduction to C++ for Python programmers
More informationCS111: PROGRAMMING LANGUAGE II
1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables
More informationKingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS
Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 1 ARRAYS Arrays 2 Arrays Structures of related data items Static entity (same size
More informationOutline. Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples.
Outline Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples. 1 Arrays I Array One type of data structures. Consecutive group of memory locations
More informationObject-Oriented Programming. Chapter 4
Data Structures Dr Ahmed Rafat Abas Computer Science Dept, Faculty of Computer and Information, Zagazig University arabas@zu.edu.eg http://www.arsaliem.faculty.zu.edu.eg/ Object-Oriented Programming Chapter
More informationA First Program - Greeting.cpp
C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout
More informationScheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C
Sample Test Paper-I Marks : 25 Time:1 Hrs. Q1. Attempt any THREE 09 Marks a) State four relational operators with meaning. b) State the use of break statement. c) What is constant? Give any two examples.
More informationLecture 3 Tao Wang 1
Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers
More information