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

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

Creating a C++ Program

Lab # 02. Basic Elements of C++ _ Part1

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

UNIT- 3 Introduction to C++

Chapter 2: Introduction to C++

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Cambridge School, Noida Practice Paper Session Subject: Computer Science Class VIII Time: 3hrs MM: 80

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

CHAPTER 4 FUNCTIONS. 4.1 Introduction

Add Subtract Multiply Divide

CHAPTER 3 BASIC INSTRUCTION OF C++

Objectives. In this chapter, you will:

C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal

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

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

6.096 Introduction to C++ January (IAP) 2009

LECTURE 02 INTRODUCTION TO C++

Class 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

A First Program - Greeting.cpp

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

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

D.A.V PUBLIC SCHOOLS, RANCHI ZONE FIRST SUMMATIVE ASSESSMENT CLASS - XI COMPUTER SCIENCE

BITG 1233: Introduction to C++

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++

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

BASIC ELEMENTS OF A COMPUTER PROGRAM

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

DEPARTMENT OF MATHS, MJ COLLEGE

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

CHAPTER-6 GETTING STARTED WITH C++

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

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

DELHI PUBLIC SCHOOL TAPI

REVIEW. The C++ Programming Language. CS 151 Review #2

Introduction of C++ OOP forces us to think in terms of object and the interaction between objects.

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Topic 2: C++ Programming fundamentals

5. Selection: If and Switch Controls

Lecture 3 Tao Wang 1

Chapter 1. Principles of Object Oriented Programming

Downloaded from

Computer Programming : C++

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

C++ Programming: From Problem Analysis to Program Design, Third Edition

Introduction to Algorithms and Programming (COMP151)

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3

CS242 COMPUTER PROGRAMMING

Getting started with C++ (Part 2)

A Freshman C++ Programming Course

A SHORT COURSE ON C++

BTE2313. Chapter 2: Introduction to C++ Programming

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?

BRAIN INTERNATIONAL SCHOOL Term-II Class-XI Sub:- Computer Science Revision Sheet

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

WT I (SET-I) Date: Class XI Sec. Time: 1 Hr. 10 min. Computer Science M.M.: 30

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Chapter 2. C++ Basics

KENDRIYA VIDYALAYA SANGATHAN, GUWAHATI REGION HALF-YEARLY EXAMINATION-2015 CLASS XI : COMPUTER SCIENCE Time Allotted : 3 hrs. Max.

The C++ Language. Arizona State University 1

Fundamental of Programming (C)

Engineering Problem Solving with C++, Etter/Ingber

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

Object Oriented Pragramming (22316)

Increment and the While. Class 15

Chapter 2 Basic Elements of C++

CSc Introduction to Computing

Professor Peter Cheung EEE, Imperial College

Programming. C++ Basics

Probably the best way to start learning a programming language is with a program. So here is our first program:

C++ PROGRAMMING SKILLS Part 2 Programming Structures

Lecture 2 Tao Wang 1

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

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

Basic Source Character Set for C++ Language:

Study Guide for Test 2

Scientific Computing

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

Full file at

Introduction to C programming. By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING

Introduction to C++ Introduction and History. Characteristics of C++

CSI33 Data Structures

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

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.1

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments

COMPUTER SCIENCE (083)

Visual C# Instructor s Manual Table of Contents

UIC. C Programming Primer. Bharathidasan University

PLT Fall Shoo. Language Reference Manual

Transcription:

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 does the following signify? i. cout : It stands for common output. It is used to display the constants, variables and expressions on the output screen. ii. cin : It stands for common input. It is used to input a value from the user and store in a variable iii. conio.h : It is a header file included in the program so the use of getch(), conio.h command can be recognized. c) Mention the shortcut key used in the following cases i. Open saved program : F3 ii. Save any c++ program : F2 iii. To compile the program : Alt + C iv. To execute the program : Alt + R d) Which command is used to give multiline output? Ans. endl e) What is the extension of C++ file? Ans..cpp f) Expand IDE Ans: Integrated Development Environment g) Identify the following operators and their category i. << Insertion operator ii. >= Relational operator iii. >> Extraction operator iv.!= relational operator v. && logical operator vi.! logical operator vii. % arithmetic operator h) Define the following terms i. Tokens : it is the smallest meaningful element of a C++ program. It defines the structure of the C++ language. These are the basic building blocks for making a program. eg. Keywords, constants, identifiers, operators etc ii. Keywords: These are the predefined words which have a specific meaning in any programming language. These words cannot be used as variables or constants. eg. int, char, float, void iii. Punctuators: these are the tokens that have a special meaning to the compiler. Eg brackets (), [], semicolon ; dot (.) 1

i) Mention the rules of defining a variable. The first character can be either an alphabet or an underscore (_) Except underscore, no other special characters are allowed while defining a variable. Variable name cannot be a keyword Both alphabet and digits can be used. Spaces are not allowed in variable name j) Match the following data type with their storage space Datatype char bool float int Storage space 1 byte 2 bytes 1 byte 4 bytes k) Identify the valid/invalid variables also write the reason for invalid variables. i. cout : invalid; keywords cannot be used ii. Hello: valid iii. First name: invalid; spaces are not allowed iv. 1name : invalid; must start with an alphabet l) Identify the header files used in the following cases i. clrscr() : conio.h ii. cin: iostream.h iii. getch(): conio.h iv. cout: iostream.h m) Differentiate between / & % operator. Ans / : it is an arithmetic operator that perform normal division. i.e it gives the quotient as the answer Eg. 5/2 will be 2.5 % it is an arithmetic operator that performs modulo division. i.e it gives the remainder as the answer Eg. 5%2 will be 1 n) Write C++ commands for the following i. Declare a character variable that stores a value P char x= P ; ii. Declare integer variable with value 10 int x=10; iii. Declare decimal variable which stores value 12.5 and has storage space 8 bytes. 2

float y=12.5; iv. Declare a Boolean variable. bool y; o) Debug the following #include<iostream> cout << hello how are you ; cout >> please remove errors and correct me ; Corrected program cout << hello how are you ; cout << please remove errors and correct me ; p) Write the output for the following program cout << 25 + 10 << endl; cout << 75-80 ; Output 25+10-5 q) Write a program in C++ to print the difference of any two numbers entered by the user. Solution cout << enter two numbers ; cin>>a; 3

cin>>b; cout << the difference is <<a-b; r) If the cost of 1 kg oranges is Rs 60/-, then using C++ write the program to find the cost of 50kg oranges. Solution int x=60; cout << the cost of 1 kg oranges is Rs 60/- ; cout << the cost of 50kgs oranges will be << 50*x; CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 2, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE Q1 Write a program in C++ to swap 2 numbers. int x,y,z; cin>> x; cin>>y; cout << the numbers are << x<< y; z=x; x=y; y=z; cout << the numbers after swapping are << x<< y; Q2 Complete the following program to print the sum of for i natural numbers. int i, _j, _s_; s=0; 4

cout<< enter the number <<endl; cin>> i; for (j=1; j<= i; j++) s=s+j; cout<< the sum of the first <<i<< numbers is << s; getch(); Q3 Differentiate between entry controlled and exit controlled loops. Entry controlled Exit controlled The loops in which the condition is tested in the The loops in which the condition is tested at the beginning end It doesn t work if the condition is not satisfied It works at least once even if the condition is not satisfied while loop do while loop Q4 If there is a single statement in place of a block of statements, then it is optional to use curly braces. (Y/N) - YES Q5 Complete the syntax of the if Q6 Debug the following program and rewrite after correcting the code. statement if (condition) statements int x=15; do else cout<< ** ; statements while x<=20 ; Q7 Convert the following program into for statement without changing the meaning of the program. clrscr(); int x=20; do cout<<x; x++; while (x<=30); getch(); 5

Solution clrscr(); int x; for ( x=20 ; x<=30 ; x++) cout<<x; getch(); Q7 Write a program to check if the number entered by user is even or odd using ternary operator. Display 0 for even and 1 for odd. clrscr(); int x,y; cout<< enter the number ; cin >> x; y=(x%2==0)? 0 : 1; cout <<y; Q8 Define a) loop(iteration) : A loop is a sequence of instructions that is continually repeated until the specified condition is true. b) Flow of control: Flow of control refers to the action taken based on different conditions in the program and execute the set of instructions accordingly. Q9 What are the three types of statements in C++. Ans The three types of statements in C++ are Branching Looping Jumping 6