CS201 Some Important Definitions

Similar documents
Short Notes of CS201

CS201 - Introduction to Programming Glossary By

For Teacher's Use Only Q No Total Q No Q No

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201 Latest Solved MCQs

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

Come and join us at WebLyceum

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Introduction to Programming Using Java (98-388)

CS201- Introduction to Programming Current Quizzes

Review of the C Programming Language for Principles of Operating Systems

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

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

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

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

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

CSCI 171 Chapter Outlines

Problem Solving with C++

UNIT- 3 Introduction to C++

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team

Model Viva Questions for Programming in C lab

Objectives. In this chapter, you will:

C++ (Non for C Programmer) (BT307) 40 Hours

KOM3191 Object Oriented Programming Dr Muharrem Mercimek OPERATOR OVERLOADING. KOM3191 Object-Oriented Programming

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

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Absolute C++ Walter Savitch

c++ keywords: ( all lowercase ) Note: cin and cout are NOT keywords.

Come and join us at WebLyceum

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

Review of the C Programming Language

Ch. 12: Operator Overloading

Introduction to C++ with content from

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

Creating a C++ Program

calling a function - function-name(argument list); y = square ( z ); include parentheses even if parameter list is empty!

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Collected By Anonymous

egrapher Language Reference Manual

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

The C++ Language. Arizona State University 1

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR


Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

C: How to Program. Week /Mar/05

Cpt S 122 Data Structures. Introduction to C++ Part II

Chapter 2: Introduction to C++

BASIC ELEMENTS OF A COMPUTER PROGRAM

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

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS

G Programming Languages - Fall 2012

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

Programming. C++ Basics

Differentiate Between Keywords and Identifiers

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Chapter 2 - Introduction to C Programming

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

Object-Oriented Programming

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

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

C++ PROGRAMMING LANGUAGE: DYNAMIC MEMORY ALLOCATION AND EXCEPTION IN C++. CAAM 519, CHAPTER 15

C++ for Java Programmers

ME 461 C review Session Fall 2009 S. Keres

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS

LECTURE 02 INTRODUCTION TO C++

Introduction to Computer Science Midterm 3 Fall, Points

Language Reference Manual simplicity

7.1 Optional Parameters

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

Typescript on LLVM Language Reference Manual

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

BITG 1233: Introduction to C++

Technical Questions. Q 1) What are the key features in C programming language?

Classes: Member functions // classes example #include <iostream> using namespace std; Objects : Reminder. Member functions: Methods.

Chapter 15 - C++ As A "Better C"

ANSI C Programming Simple Programs

1 Lexical Considerations

Introduction to Programming using C++

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

Homework #3 CS2255 Fall 2012

Object Oriented Programming. Solved MCQs - Part 2

Object Oriented Design

Programming in C++ 5. Integral data types

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

2 nd Week Lecture Notes

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

The SPL Programming Language Reference Manual

An Introduction to C++

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

C++ PROGRAMMING LANGUAGE: CLASSES. CAAM 519, CHAPTER 13

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS

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

In Java we have the keyword null, which is the value of an uninitialized reference type

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

SAURASHTRA UNIVERSITY

Transcription:

CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data members, and functions. We call this program class. 3. What are data members? The data members, functions and nested classes are called class members. 4. What is class layout? The way in which data class members are arranged in a class object is called class layout. 5. What is class template? A template is used for generating class types. 6. What is comment in Programing language? Comments are used to explain the functioning of the programs. It helps to understand the code. C style of commenting is /*..*/ also used in C++. And new line oriented C++ style is // 7. What is a constructor? A constructor initializes the data member of an object in the scope. It has no return type, and has the same name as class. We use many types of constructor by overloading them. Types of constructor: Default constructor/compiler generated constructor Simple constructor (takes no arguments) Parameterized constructor (takes arguments) Constructor overloading Copy constructor 8. What is destructor? A function called when a class object goes out of scope. It cleans up the object, freeing resources like dynamic storage. The name of the destructor is the same as that of a class with preceding tilde sign (~). It could not be overloaded. It has no return type, and takes no argument.

9. Define #include? The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with <..> if the file is a system provided file, or in quotes. if the file is user provided. 10. For which purpose we use cout? If we want to print something on the screen we use cout (Output stream) for this purpose. 11. What are Variables? Variables are locations in memory for storing data. We call them variables because they can contain different values at different times. The variable name in C may be started with a character or an underscore ( _ ).But in C++ we did not use underscore _. In a program every variable has: Name Type Size Value 12. What are data types? A variable must have a data type associated with it. It can have data types like integers, decimal numbers, characters etc. Different data types have different size in memory. 13. Operators: Assignment operator : = is used to assign a value to a specific location. Compound assignment operators: += -= *= /= %= Modulus Operator: % is used to get the remainder. (For division) Relational Operators: <, =, > used for decision making (in if statement) > greater than == equal to < less than >= greater than or equal to <= less than or equal to

!= not equal to Logical Operators: (These are binary operators and take two operands) && AND operator OR operator! Logical Negation Increment and decrement operator: ++ Increment operator (unary operator) that increase the value of its operator by 1. - -(with no space between) decrement operator that decrease the value by 1. Address operator: & to get the address of a memory location. 14. What is operator overloading? Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the operands. 15. What is if statement? The statement used for decision in C language is known as the if statement it also called conditional statement. It has a simple structure: If(condition) Statement (or group of statements) For example: If(Ali s height is greater than six feet) Ali can be a member of team 16. What is if/else statement structure? If(condition){ statement(s); else{ Statement(s); 17. When we use switch statement? The switch structure is a multiple-selection construct that is used in multi way decisions to make the code more efficient and easy to understand. Multi decision means a condition where we have to use if else statement again and again so for ease to access we use switch statement. In switch statement there should be an integer variable or an expression which must evaluate an integer type. We can t use compound conditions (conditions that use logical operators &&, in switch statement).

18. What is break statement? The break statement interrupts the flow of control. In switch statement all statements are executed. But we want that only statements of true case should be executed and remaining should be skipped. For this purpose we use break statement. Syntax of switch and break statement: switch(variable/expression){ case constant1: statement 1; break; case constant2: statement2; break; case constantn: statmentn; break; default: statement; 19. What is the purpose of continue statement? Continue statement is related to loop. When we have lot of code in the body of loop and we need some code to be executed every time and some code in certain cases. For this purpose we use continue statement. It one line statement like break statement. continue; The statements of the loop body after continue are not executed. And loop starts from the next iteration when a continue statement is encountered in the body of the loop. 20. When will be used while Loop? While means do it until the condition is true. Use of while construct can be helpful in repeating of a set of instructions under some condition. The syntax of while construct is: while(logical expression){ statement 1; statement 2; statement 3; 21. What is the difference between while and do-while loop? In while loop the condition is tested first and the statement in the body executed only when the condition is true, the loop can executed zero or more times.

In do-while loop condition is tested after execution the statement of the loop body. Thus, the loop body executed at least once and then the condition in do while stamen is tested. Syntax of do while Loop: do{ statement(s); while(condition); 22. What we do in the loop? There are three things we do in a loop: i. Initialize a variable. ii. A continuation / termination condition iii. Changing the value of the condition variable, usually the increment of the variable value. The syntax of for loop: for(initialize condition; continuation condition; incrementing condition) { statement(s); 23. What are functions? Functions are like subtasks. They receive some information, do some process and provide a result. There are two categories of function: Functions that returns a value Functions that do not return a value. Structure of Functions: Structure of function return-data-type function-name(argumentlist){ declarations and statements Example int square(int number){ int result = 0; result = number*number; return result; Functions which don t return any value use keyword void instead of return-data-type. The default data type of functions is int. 24. What is the calling methodology of a function? The calling program just needs to write the function name and provide its arguments without data types.

25. What is the difference between declaration and definition of a function? Declaration and definition are both different things. Declaration is a prototype of the function, that includes the return type, name and argument list to the function and definition is the actual function code. Declaration Int square (int) Definition Int square(int number){ Return (number * number); 26. What is the difference between call by value and call by reference? Call by Value: In call by value we pass a copy of arguments instead of original variables. The copy reaches to the function that uses it and returns it back to the calling function. (C language use call by value by default). Call by Reference: In call by reference we pass the reference of original variable. And use original variable. 27. What is array? Array is a special data type. Arrays can be used to store a collection of data of same data type. Every array has a data type name and size. Arrays start from index 0. Declaration: Data-type array-name[size]; For example: Int ages[10]; We can initialize an array using loop while assigning some value. 28. Define keyword const. The keyword const is the construct. If we want to change the size of an array suppose from 10 to 100 we can use this keyword to deal this situation. It can be used for any data type and is written before the data type as: const int arraysize = 100; Whenever we use the word key word const the value of that variable becomes constant and no other value can be assigned to it later on. 29. How we can manipulate arrays? We can manipulate arrays using loops. 30. What are pointers? Pointers are a special type of variables in which a memory address is stored. (They contain memory address not the value of the variable). Pointers works by pointing to a particular data type i.e. int, char, double, float etc.

The syntax of declaring a pointer is: Data type *name; For example int *myptr; One of the major usages of pointers is to simulate call by reference while using it with function calls. In the calling function, we pass the address of the variable to a function being called by using & operator. 31. What is bubble sort? It is a technique of comparing two values and interchanging the larger and smaller values. To interchange the position of larger and smaller values, the technique of swapping is used. 32. What is the relationship between pointers and arrays? The name of array is a constant pointer which contains the memory address of the first element of the array. 33. What is the role of a back slash (\) in C and C++? Whenever a back slash (\) is used, the compiler consider both the characters as single (also known as escape characters). \n for new line \t for tab \0 null 34. What do you know about <ctype.h>? C language provides any functions to perform useful tests and manipulations of character data. These functions are found in the header file <ctype.h>. 35. What do you know about <stdlib.h>? The header file stdlib.h includes functions, used for different conversions. These conversion functions take an argument of a type and return it after converting into another type. 36. Which header file we use for file handling in our programs? Whenever using files in our programs, we will include this header file <fstream.h>. 37. What is a structure? A structure is a collection of variables under a single name. These variables can be of different types, and each has a name that is used to select it from the structure. It is defined with the key word struct. (Keyword struct cannot be used as variable.) 38. What is static memory allocation? When we write the things like int i, j, k these will reserve three integers in memory. Similarly the typing of char s[20] will result in the allocation of space for 20characters in the memory. This type of memory allocation is called static

allocation. It is also called compile time allocation. Static memory runs essentially on stack. We use this type of allocation when we know how much memory is required. 39. What is dynamic memory allocation? Instead of allocating static memory with in code, we can ask how much memory is required to allocate. And allocate memory at runtime (dynamically). This type of memory allocation is used when we don t know how much memory exactly we required. The dynamic memory allocation use memory from heap. 40. Which functions are used for memory allocation in C? calloc(), malloc() and realloc() functions are used for memory allocation in C. 41. For which purpose Function free() is used? The memory allocated is no longer in use, we use free() function to free that memory and make it a part of heap again. 42. How memory allocated in C++? The memory allocation in C++ is carried out with the use of an operator called new operator, and deallocated with the delete operator. That memory returned back to free store. Whenever we use new operator to allocate memory, it will be necessary to use of delete operator to deallocate the memory. 43. What is dangling pointer? The pointer points to no memory location is called dangling pointer. It has inverse effect of memory leak. A pointer was pointing to a chunk of memory, now by some reason that memory has deallocated and has gone back to heap. The pointer still has the starting address of that chunk. Now pointer is pointing to a memory that no longer belongs to the program and gone back to the heap. 44. Define static variable also explain life time of static variable? Static variable means maintaining the state of a variable. It exists and lives around even when we are outside the function. It is created and initialized only once during the lifetime of the program and therefore it will be destroyed or taken out of memory only once during the lifetime of the program. 45. What is different between pointers and variable? Normal variable contains the value of variable either int or float whereas pointer variable contains the address of another variable. 46. How many types of templates? There are two different types of templates in C++ language i.e. function templates and class templates.

47. Define buffer? A program that writes the output data to the disc, it will be nice to collect the output data (numbers) and write it on the disc in one write operation instead of writing the numbers one by one. The area where we gather the numbers is known as buffer. 48. What is function overloading? In function overloading, the functions have the same name but differ either by the number of arguments or the type of the arguments. 49. What is the keyword this and what are the uses of this pointer? 'This' is used to refer the current class member without using the name of the class. We cannot use it as a variable name. this pointer is present in the function, referring to the calling object. this pointer points to the current object.