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

Size: px
Start display at page:

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

Transcription

1 NAGERCOIL COMPUTER SCIENCE Grade: IX C++ PROGRAMMING 1

2 C++ 1. Object Oriented Programming OOP is Object Oriented Programming. It was developed to overcome the flaws of the procedural approach to programming. In OOP the problem is divided into a number of entities called objects. The data is passed directly to these objects. These objects can interact with each other. A Language is called as OOP Language if it supports all the Features of the OOP Language Objects: Essence of OOP OOP is a powerful way to create programs, and it makes the program you write more useful. Consider Word processing software. It could be divided into various objects: A document object, which is the area where you type in text. A spell checking object, which looks over the document to find spelling errors. A printer object, which handles printing of the document. A menu object, a mouse object and many other objects Benefits of OOP Object Oriented Programming is being used extensively for software development today. This technology makes programming easier and error - free. Software is easily managed, as it is divided in various objects, which can easily partition the whole project. The upgrading of software is also easy, as only some objects need to be replaced instead of the whole software. Also we can write programs from the standard working programs by extending their behaviour rather than starting from scratch. For these reasons, OOP is becoming a norm for software development Need to Write C++ Programs Before you can start to write C++ programs, you need to acquire some kind of programming software. Although several products are available for the development of C++ programs, the starting place is either Turbo C++ package or Microsoft Visual C++ package, which includes C++ programming environment and a C++ compiler. Every Programming language requires a compiler or interpreter. The Compiler takes a computer program and translates it into a binary form that the computer understands. ie. in 0 & 1 form. Several free C++ compilers are available on the internet. Some of which might be difficult to operate for amateurs. 2

3 Answer the following 1. Write short note on C Write the benefits of C Explain the various objects of OOPs? ************************* 2. Structure of a C++ Program Every C++ program contains a number of several building blocks as functions. Each function of it performs task independently. A function is subroutine that may consists of one or more statements. A C++ program comprises of the following sections. Include Header File Sections Global Declaration Section /* Comments */ main() /* comments */ Declaration Part Executable Part User defined functions 2.1. Include Header File Section C++ program depends upon some header files for function definition. Each header file by default is extended with.h. The file should be included using #include directive. Example: #include<iostream.h> #include<conio.h> 2.2. Global Declaration This section includes some variables that are used in more than one function. These variables must be declared outside of all the functions. 3

4 2.3. Function main() Every program written in c language must contain main( ) function. Empty parenthesis after main is necessary. The function main() is the starting point of every C++ program. The execution of the program always begins with the function main (). Except the main () function, other sections may not be necessary. The program execution starts with opening brace and ends with closing brace. Between this braces the programmer should declare the declaration and executable part Declaration part The declaration part declares the entire variables that are used in executable part. The initialization means providing initial value to the variable Execution part This part contains the statements following the declaration of the variables. This part contains a set of statements or a single statement. These statements are enclosed between the braces User defined functions The functions defined by the user are called user-defined functions. These functions are generally defined after main() function. This portion is not compulsory Writing C++ code The proper way of writing C++ code is called the Syntax. Syntax is a mixture of: C++ keywords like int, for and return. Constants and variables Operators like +(arithmetic addition ), (logical or ) and & (the address of operator) Answer the following 1. Write the structure of C++ program and explain? 2. What is the role of braces in C++ program? 3. What header file must you include with your source file to use cout and cin? 4. Why is function main() special? ********************** 4

5 3. Input and Output statements 3.1.Outputting Values: To output a value, we use cout. Here s an example: cout<< the value of x is \n <<x; All most all the text within the quote marks is printed out onto the screen except escape char. Instead of printing out the variable name, the numerical value of x is printed out. The \n is a special character- the new line character. In C++ we use cout statement to display the output and cin statement to take the input. Both of these tools are in a header file called iostream.h. So as the first line of our program we have to include the header file iostream.h. This can be done by using the statement #include. This statement is meant for the pre-processor and not the C++ Compiler. Every statements starting with the symbol # is meant for pre-processor. These are called as pre-processor directives. Whenever we need to display anything on the screen we can use the cout statement. cout is just like a projector. Anything send to the cout will be displayed on the screen of the computer. If we want to display a group of words as such on the screen we will have to enclose that in double quotations and send it to the cout. Eg: cout<< Hello this is displayed on the screen ; When this gets executed we will see the group of words on the screen. The symbol << is called insertion operator. If there is more than one group of words it should be inserted in to the cout using multiple insertion operators. Eg: cout<< One group << second group << third group ; This type of usage of multiple insertion operators is called cascading.if we want to show any matter stored in a memory position to the screen using cout we will have to type in the name of memory position without enclosing the name in double quotations Input cin is used in the same way to input some value from the keyboard. Ex: cin>>a; 5

6 The statement directly assigns the value entered by the keyboard to the variable a. Here is a sample program demonstrating the use of a variable: #include <iostream.h> int main() inta,b,c; /* Declare variables*/ cout<<"enter two integers separated by a space: "; cout<< and I will work out their sum!\n ; cin>> a>>b; c=a+b; cout<<a<< plus <<b<< is equal to <<c <<"\n"; return 0; 3.3. Commenting the code You can add comments to your code by enclosing your remarks within /* and */ or by placing a // before a line. However, nested comments ie. Placing a comment within comment within a comment is not allowed 3.4. Advantages of commenting They can be used to tell the person viewing the code which part of the code does what. This is helpful when you revisit the code at a later date. The compiler ignores all the comments. This means that comments do not affect the efficiency of the program. You can use /* and */ to comment out sections of the code when it comes to finding the errors, instead of deletion. Answer the following 1. What are input and output statements? 2. What is the input operator >> and output operator << called? 3. Write the advantages of comments? 6

7 Try in your lab 1. Write a C++ program to print welcome to C++ program. 2. Write a C++ program to find the sum of two numbers. 3. Write a C++ program to find the sum and average of two numbers. **************************** 4. Constants and Variables 4.1. Constants Constants are data items whose values cannot be changed. A constant is of numeric or nonnumeric type. Numeric constants consist of only numbers, either whole numbers or decimal numbers. Integer, floating-point are numeric constants Integer Constant Integer Constant must have at least one digit and must not contain any fractional part. May be prefixed with a + or sign A sequence of digits starting with 0 (zero) is treated as Octal constant Ex. 010 = 8 ( [8] 10 = [10] 8 ) A sequence of digits starting with 0xis treated as hexadecimal integer. Ex. 0xF = 15 ( [15] 10 = [F] 16 ) Floating Point Constant Floating Point Constant is a signed real number. It includes an integer portion, a decimal point, a fractional portion and an exponent. While representing a floating point constant the integer portion or the decimal portion can be omitted but never both. For example is a valid floating point (Real) constant. It can be represented in exponent form as follows: 5.864E1 => x 101 => E-2 => 5864 x 10 2 => E2 => x102 => The letter E or e is used to represent the floating-point constant exponent form Character Constant Character constant is a constant that contains a single character enclosed within single quotes. It can be any character as defined in the character set of C++ language (alphabet, numeral, mathematical, relational or any other special character as part of the ASCII set). Certain special 7

8 characters like tab, backspace, line feed, null, backslash are called as non-graphic character constants. These characters are represented using escape sequences. Escape sequences are represented using characters prefixed with a backslash Escape Sequence Nongraphic Character \a - Bell \b - Back space \n - New line/ line feed \t - Horizontal tab \v - Vertical tab \\ - Back slash \ or \ - Single / double quotes \o - Octal number \x - Hexadecimal number \0 - Null 4.3. Variables There are several rules that you must follow when naming variables: Variables name rules Example Cannot start with a number 2times Can contain a number elsewhere Times2 Cannot contain any arithmetic operators A *b+c or any special punctuation marks! Result 99 Cannot be a C++ keyword while Cannot contain a space Hello world Can start with or contain an underscore Who_is_that Can be of mixed cases AvkCbse 4.4. Expressions and Statements A statement is a building block of a program. For example the assignment statement int a=10; 8

9 This is also an expression and has the value 10. If we write this code int b= (a=10) ; Both a and b will be set to the value Conditional Expression A conditional expression is one which evaluates as true (a non zero value) or false (0). True is almost always 1 but any non zero value is also true! A zero value is false, anything else is true. Ex: #include <iostream.h> int main() int a=10; int b=( a = 10) ; int c=( a==10) ; cout<< "Value of b is " << b <<endl ; cout<< "Value of c is " << c <<endl ; return0; Compile and run the example above. It should print out the following. Value of b is 10 Value of c is The const Keyword The const keyword is used to create a read only variable. Once initialized, the value of the variable cannot be changed but can be used just like any other variable. const syntax : main() const float pi = 3.14; The const keyword is used as a qualifier to the following data types 9

10 int float char double constint degrees = 360; const float pi = 3.14; const char quit Answer the questions: = 'q'; 1. How are integer constants represented in C++? Explain with examples. 2. What are character constants in C++? How are these implemented? 3. What is escape sequence? Give example. 4. What are the rules for naming a variable? 5.1. C++ character set ****************************** 5. Data Types Like the C language, C++ also comprises a character set from which the tokens (basic types of elements essential for programming coding ) are constructed. The character set comprises of A.. Z, a.. z, 0.. 9, +, -, /, *,\, (, ), [, ],,, =,!=, <, >,., ; : %,!, &,?, _, #, <=, white space, horizontal tab, carriage return and other characters. Let us write a program to print Hello using chars #include<iostream.h> int main() char a,b,c,d,e; a= H ; /* correct way*/ /* a = H is wrong */ b= e ; c= l ; d= I ; e= o ; cout<<a<<b<<c<<d<<e<< \n ; return 0; This program just prints Hello as its output. 10

11 5.2. Integers Whole numbers are integers(called int). The int variable type can store values from to in C++. Valid integer assignment instructions is int a= 8 is invalid. They occupy 2 bytes in the computer memory Floating Point numbers: Integers are great for counting whole numbers, but sometimes we need to store very large numbers, or numbers with a fractional component. A floating point type variable is a variable that can hold a real number, such as 4.0, 2.5, 3.33, or There are three different floating point data types: float, double, and long double. A float is usually 4 bytes and a double 8 bytes, but these are not strict requirements, so sizes may vary. Long doubles were added to the language after it s release for architectures that support even larger floating point numbers. But typically, they are also 8 bytes, equivalent to a double. Floating point data types are always signed (can hold positive and negative values). Here are some declarations of floating point numbers: 1 float fvalue; 2 double dvalue; 3 long double dvalue2; The floating part of the name floating point refers to the fact that a floating point number can have a variable number of decimal places. For example, 2.5 have 1 decimal place, whereas has 4 decimal places. When we assign numbers to floating point numbers, it is convention to use at least one decimal place. This helps distinguish floating point values from integer values. 1 2 int nvalue = 5; // 5 means integer float fvalue = 5.0; // 5.0 means floating point 5.4. Declaring Variables in C++ To declare a variable you use the syntax "type <name>;". Here are some variable declaration examples: Int x; char letter; float the_float; 11

12 It is permissible to declare multiple variables of the same type on the same line; each one should be separated by a comma. int a, b, c, d; The declaration of a variable is always followed by a semicolon Common Errors when Declaring Variables in C++ If you attempt to use a variable that you have not declared, your program will not be compiled or run, and you will receive an error message informing you that you have made a mistake. Usually, this is called an undeclared variable Case Sensitivity Now is a good time to talk about an important concept that can easily throw you off: case sensitivity. Basically, in C++, whether you use uppercase or lowercase letters matters. The words Cat and cat mean different things to the compiler. In C++, all language keywords, all functions and all variables are case sensitive. A difference in case between your variable declaration and the use of the variable is one reason you might get an undeclared variable error. Answer the questions: 1. Explain integer data types 2. Explain floating point numbers 3. How will you declare a variable? *************************** 6. Operators 6.1. Arithmetic Operators Arithmetic Operators are used to perform mathematical operations. The list of arithmetic operators are :+, -, * multiplication operator, / division operator, % modulus operator - gives the remainder of an integer division, +=, -=, *=, /=, %=. Arithmetic expressions are formed using arithmetic operators, numerical constants/variables, function call connected by arithmetic operators Assignment operator a = 5; takes the slot reserved for a and puts the value 1 into it. 12

13 6.3. Arithmetic Assignment Operators Examples: a =+b; is the same as x=x+y; a /= 5; (a = a/5) a *= 2 ( a = a * 2) a %= 5 ( a = a/5) a = b + pow(x,y) ( a = b + x y ) 6.4. Increment and Decrement operators a++; - (Post increment operator. Equivalent to a = a+1) a- - ; - (Post decrement operator. Equivalent to a = a-1) ++a; - (Pre increment operator. Equivalent to a = a+1) - - a ; - (Pre decrement operator. Equivalent to a = a 1) Operators are executed in the order of precedence. The operands and the operators are grouped in a specific logical way for evaluation. This logical grouping is called as association. Answer the questions: 1. Write a program to find the area and circumference of circle 2. Write a program to find the area of square 3. Write a program to find the area of rectangle 4. Write a program to find the area of triangle 5. Write a program to calculate simple interest 6.5.Relational Operators Relational Operators are used to compare values. The lists of relational operators are = = equal to > greater than < lesser than >= greater than or equal to <= lesser than or equal to!= not equal to Relational operators are used to compare numeric values. A relational expression is constructed using any two operands connected by a relational operator. For example the relational operators are used to construct conditions such as 13

14 10 > <= != = = 9 The result of a relational operation is returned as true or false.the numeric constant zero (0) represents False value, and any nonzero constant represents true value. The above expressions output will be 0 (10 > 20 is false ) ; 1 ( < 1005 is evaluated to True hence any non zero constant) ; 1 (99!= 99.5 will be evaluated to True hence non zero constant) 1 ( 9 = = 9 will be evaluated to true, hence the output will be non zero constant) 6.6. Logical Operators (Boolean Operators) Logical operators combine the results of one or more operators combines the results of one or more conditions. The various logical operators are &&(AND) (OR)! (NOT) AND operator The logical AND operator (&&) returns the boolean value true if both operands are true and returns false otherwise. The operands are implicitly converted to type bool prior to evaluation, and the result is of type bool. Logical AND has left-to-right associatively. The operands to the logical AND operator need not be of the same type, but they must be of integral or pointer type. The operands are commonly relational or equality expressions. The first operand is completely evaluated and all side effects are completed before continuing evaluation of the logical AND expression OR operator The second operand is evaluated only if the first operand evaluates to true (nonzero). This evaluation eliminates needless evaluation of the second operand when the logical AND expression is false. 14

15 The logical OR operator () returns the boolean value true if either or both operands is true and returns false otherwise. The operands are implicitly converted to type bool prior to evaluation, and the result is of type bool. Logical OR has left-to-right associatively. The operands to the logical OR operator need not be of the same type, but they must be of integral or pointer type. The operands are commonly relational or equality expressions. The first operand is completely evaluated and all side effects are completed before continuing evaluation of the logical OR expression. The second operand is evaluated only if the first operand evaluates to false (0). This eliminates needless evaluation of the second operand when the logical OR expression is true. Ex: cout (x == w x == y x == z)); In the above example, if x is equal to either w, y, or z, the second argument to the printf function evaluates to true and the value 1 is printed. Otherwise, it evaluates to false and the value 0 is printed. As soon as one of the conditions evaluates to true, evaluation ceases NOT operator This operator negates the expression. If the expression returns true this operator changes it to false and if the expression returns false, it changes it to true. Answer the questions: 1. Explain relational operator. 2. Explain logical operator. Write a program to find the maximum among two integers. Max = ((a+b) + abs(a-b))/2 ************************* 7.1.IF statement 7. Control Structure The if statement allows you to control if a program enters a section of code or not based on whether a given condition is true or false. One of the important functions of the if statement is that it allows the program to select an action based upon the user's input. For example, by using an if statement to check a user entered password, your program can decide whether a user is allowed access to the program. 15

16 The structure of an if statement is as follows: if (condition/expression) Action block1; Example: If (5<10) cout<< Five is now less than ten ; Simple if statement program # include <iostream.h> # include <conio.h> void main() int a; clrscr(); cout<< \nenter a number ; cin>> a; if ( a%2 == 0) cout<< \nthe given number << a << is even ; getch(); 7.2. The Else statement: If the condition is not true, sometimes you want the program do something as a last resort. So, after if statement, you can use as else statement. Ex. /* to find the input number is even or odd */ # include <iostream.h> # include <conio.h> void main() 16

17 int a; clrscr(); cout<< \nenter a number ; cin>> a; if ( a%2 == 0) cout<< \nthe given number << a << is even ; else cout<< \nthe given number << a << is odd ; getch(); In the above program The given number 10 is even is printed if the expression is evaluated to true, otherwise statement following else option will be executed. Answer the questions: 1. Write a program to find the biggest among two given number 2. Write a program to find the smallest among two given number 3. Write a program to find the smallest among three given number **************************** 8. Nested if Another use of else is when there are multiple conditional statements that may all evaluate to true, yet you want only one if statement's body to execute. You can use an "else if" statement following an if statement and its body; that way, if the first statement is true, the "else if" will be ignored, but if the if statement is false, it will then check the condition for the else if statement. If the if statement was true the else statement will not be checked. It is possible to use numerous else if statements to ensure that only one block of code is executed. Syntax : if ( condition / expression ) // Execute these statements if <condition> is TRUE else if ( another condition/expression ) 17

18 // Execute these statements if <another condition> is TRUE and <condition> is FALSE Ex: #include <iostream.h> int main() int a,b; cout<< Input two integers separated with a space :\n ; cin>>a>>b; if (a==b) cout<<a<< is equal to <<b<< \n ; elseif (a<b) cout<<a<< is less than <<b<< \n ; else cout<<a<< is greater than <<b<< \n ; return 0; 9. The Conditional Operator 9.1 Conditional Operator (?:) (num1 > num2)? true : else -?: Is a ternary operator (num1>num2, true, false are the operands. A ternary operator (?:) is also called as conditional operator. The general syntax is E1?E2 : E3 where E1,E2,E3 are operands. E1 should essentially be of scalar type, E2 and E3 are values or statements. For example to assign the maximum value of the two values one can express it as :max = (num1 > num2)? num1 : num2; The variable max will take the value of num1 if num1 is greater than num2, otherwise max will be assigned with the value of num2. a?b:c Where a is a condition, b is an expression that is performed when the condition is true otherwise the expression in c is performed. Ex: x==10? cout<< x is equal to 10\n : cout<< x is not equal to 10\n ; 1. Write a program to find the biggest among 2 given number 18

19 10. Loop Types 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 first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows us to execute a statement or group of statements multiple times and following is the general from of a loop statement in most of the programming languages: C++ programming language provides the following type of loops to handle looping requirements. 10. Loop Type Description while loop While loop repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body for loop for loop execute a sequence of statements multiple times and abbreviates the code that manages the loop variable. 19

20 10.3.do...while do...while loop Like a while statement, except that it tests the condition at the end of the loop body nested loops Nested loop you can use one or more loop inside any another while, for or do..while loop While Loop A while loop statement repeatedly executes a target statement as long as a given condition is true. Syntax The syntax of a while loop in C++ is: while(condition) statement(s); Here, statement(s) may be a single statement or a block of statements.the condition may be any expression, and true is any non-zero value. The loop iterates while the condition is true.when the condition becomes false, program control passes to the line immediately following the loop. Flow Diagram Here, key point of the while loop is that the loop might not ever run. When the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed. 20

21 Example #include <iostream> using namespace std; int main () // Local variable declaration: int a = 10; // while loop execution while( a < 20 ) cout<< "value of a: " << a <<endl; a++; return 0; When the above code is compiled and executed, it produces the following result: value of a: 10 value of a: 15 value of a: 11 value of a: 16 value of a: 12 value of a: 17 value of a: 13 value of a: 18 value of a: 14 value of a: for Loop A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. 21

22 Syntax The syntax of a for loop in C++ is: for ( initialization; condition; increment ) statement(s); Here is the flow of control in a for loop: a. The initialization step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears. 22

23 b. Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and flow of control jumps to the next statement just after the for loop. c. After the body of the for loop executes, the flow of control jumps back upto the increment statement. This statement allows you to update any loop control variables. This statement can be left blank, as long as a semicolon appears after the condition. d. The condition is now evaluated again. If it is true, the loop executes and the process repeats itself (body of loop, then increment step, and then again condition). After the condition becomes false, the for loop terminates. Example: #include <iostream> int main () // for loop execution for(int a = 10; a < 20; a = a + 1 ) cout<< "value of a: " << a <<endl; return 0; When the above code is compiled and executed, it produces the following result: value of a: 10 value of a: 15 value of a: 11 value of a: 16 value of a: 12 value of a: 17 value of a: 13 value of a: 18 value of a: 14 value of a: 19 Unlike for and while loops, which test the loop condition at the top of the loop,the do...while loop checks its condition at the bottom of the loop do..while loop A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time. 23

24 Syntax The syntax of a do...while loop in C++ is: do statement(s); while( condition ); Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop execute once before the condition is tested. If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop execute again. This process repeats until the given condition becomes false. Flow Diagram 24

25 Example #include <iostream.h> int main () // Local variable declaration: int a = 10; // do loop execution do cout<< "value of a: " << a <<endl; a = a + 1; while( a < 20 ); return 0; When the above code is compiled and executed, it produces the following result: value of a: 10 value of a: 15 value of a: 11 value of a: 16 value of a: 12 value of a: 17 value of a: 13 value of a: 18 value of a: 14 value of a: 19 Answer the questions: 1. Write a program to print 1 to Write a program to print all even numbers from 1 to Write a program to print all odd numbers from 20 to

26 Nested Loop A loop can be nested inside of another loop. C++ allows at least 256 levels of nesting. Syntax The syntax for a nested for loop statement in C++ is as follows: for (initialization; condition; increment ) for (initialization; condition; increment ) statement(s); statement(s); // you can put more statements. The syntax for a nested while loop statement in C++ is as follows: while(condition) while(condition) statement(s); statement(s); // you can put more statements. The syntax for a nested do...while loop statement in C++ is as follows: do statement(s); // you can put more statements. Do statement(s); while( condition ); 26

27 while( condition ); Example The following program uses a nested for loop to find the prime numbers from 2 to 100: #include <iostream.h> using namespace std; int main () int i, j; for(i = 2; i<100; i++) for(j = 2; j <= (i/j); j++) if(!(i%j)) break; // if factor found, not prime if(j > (i/j)) cout<< i << " is prime\n"; return 0; This would produce the following result: 2 is prime 3 is prime 5 is prime 7 is prime 11 is prime 13 is prime 17 is prime 19 is prime 23 is prime 29 is prime 31 is prime 37 is prime 41 is prime 43 is prime 47 is prime 53 is prime 59 is prime 61 is prime 67 is prime 71 is prime 73 is prime 79 is prime 83 is prime 89 is prime 97 is prime 27

28 Write a C++ program to print the following output ***************************** 28

UNIT- 3 Introduction to C++

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

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

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

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

Objectives. 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++ 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 information

Chapter 2: Basic Elements of C++

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

BITG 1233: Introduction to C++

BITG 1233: Introduction to C++ BITG 1233: Introduction to C++ 1 Learning Outcomes At the end of this lecture, you should be able to: Identify basic structure of C++ program (pg 3) Describe the concepts of : Character set. (pg 11) Token

More information

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

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

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

PART I.   Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++. Unit - III CHAPTER - 9 INTRODUCTION TO C++ Choose the correct answer. PART I 1. Who developed C++? (a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai 2. What was the original name

More information

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

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

2 nd Week Lecture Notes

2 nd Week Lecture Notes 2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous

More information

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

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

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

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

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

Chapter 2: Introduction to C++

Chapter 2: Introduction to C++ Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++

More information

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

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley

More information

CHAPTER-6 GETTING STARTED WITH C++

CHAPTER-6 GETTING STARTED WITH C++ CHAPTER-6 GETTING STARTED WITH C++ TYPE A : VERY SHORT ANSWER QUESTIONS 1. Who was developer of C++? Ans. The C++ programming language was developed at AT&T Bell Laboratories in the early 1980s by Bjarne

More information

LECTURE 02 INTRODUCTION TO C++

LECTURE 02 INTRODUCTION TO C++ PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION

More information

A First Program - Greeting.cpp

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

Creating a C++ Program

Creating a C++ Program Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an

More information

Objectives. In this chapter, you will:

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

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

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols. EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic

More information

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

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja

More information

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

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

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Computer Programming : C++

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

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

Lab # 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 information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

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

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

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Basic structure of C programming To write a C program, we first create functions and then put them together. A C program may contain one or more sections. They are

More information

JAVA Programming Fundamentals

JAVA Programming Fundamentals Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

CHAPTER 3 BASIC INSTRUCTION OF C++

CHAPTER 3 BASIC INSTRUCTION OF C++ CHAPTER 3 BASIC INSTRUCTION OF C++ MOHD HATTA BIN HJ MOHAMED ALI Computer programming (BFC 20802) Subtopics 2 Parts of a C++ Program Classes and Objects The #include Directive Variables and Literals Identifiers

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

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

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

REVIEW. The C++ Programming Language. CS 151 Review #2 REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,

More information

Java Notes. 10th ICSE. Saravanan Ganesh

Java Notes. 10th ICSE. Saravanan Ganesh Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses

More information

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm. CHAPTER 1&2 OBJECTIVES After completing this chapter, you will be able to: Understand the basics and Advantages of an algorithm. Analysis various algorithms. Understand a flowchart. Steps involved in designing

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Chapter 2. Lexical Elements & Operators

Chapter 2. Lexical Elements & Operators Chapter 2. Lexical Elements & Operators Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr The C System

More information

CSc Introduction to Computing

CSc Introduction to Computing CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments

More information

Lecture 2 Tao Wang 1

Lecture 2 Tao Wang 1 Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors

More information

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

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program Overview - General Data Types - Categories of Words - The Three S s - Define Before Use - End of Statement - My First Program a description of data, defining a set of valid values and operations List of

More information

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More information

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

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

These are reserved words of the C language. For example int, float, if, else, for, while etc.

These are reserved words of the C language. For example int, float, if, else, for, while etc. Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.

More information

Java Programming Fundamentals. Visit for more.

Java Programming Fundamentals. Visit  for more. Chapter 4: Java Programming Fundamentals Informatics Practices Class XI (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra, PGT (Comp.Sc.)

More information

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA. DECLARATIONS Character Set, Keywords, Identifiers, Constants, Variables Character Set C uses the uppercase letters A to Z. C uses the lowercase letters a to z. C uses digits 0 to 9. C uses certain Special

More information

Chapter 2: Overview of C++

Chapter 2: Overview of C++ Chapter 2: Overview of C++ Problem Solving, Abstraction, and Design using C++ 6e by Frank L. Friedman and Elliot B. Koffman C++ Background Introduced by Bjarne Stroustrup of AT&T s Bell Laboratories in

More information

Maciej Sobieraj. Lecture 1

Maciej Sobieraj. Lecture 1 Maciej Sobieraj Lecture 1 Outline 1. Introduction to computer programming 2. Advanced flow control and data aggregates Your first program First we need to define our expectations for the program. They

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

Basics of Programming

Basics of Programming Unit 2 Basics of Programming Problem Analysis When we are going to develop any solution to the problem, we must fully understand the nature of the problem and what we want the program to do. Without the

More information

Getting started with C++ (Part 2)

Getting started with C++ (Part 2) Getting started with C++ (Part 2) CS427: Elements of Software Engineering Lecture 2.2 11am, 16 Jan 2012 CS427 Getting started with C++ (Part 2) 1/22 Outline 1 Recall from last week... 2 Recall: Output

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

Input And Output of C++

Input And Output of C++ Input And Output of C++ Input And Output of C++ Seperating Lines of Output New lines in output Recall: "\n" "newline" A second method: object endl Examples: cout

More information

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

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered )   FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING ( Word to PDF Converter - Unregistered ) http://www.word-to-pdf-converter.net FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING INTRODUCTION TO C UNIT IV Overview of C Constants, Variables and Data Types

More information

REPETITION CONTROL STRUCTURE LOGO

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

Operations. Making Things Happen

Operations. Making Things Happen Operations Making Things Happen Object Review and Continue Lecture 1 2 Object Categories There are three kinds of objects: Literals: unnamed objects having a value (0, -3, 2.5, 2.998e8, 'A', "Hello\n",...)

More information

ANSI C Programming Simple Programs

ANSI C Programming Simple Programs ANSI C Programming Simple Programs /* This program computes the distance between two points */ #include #include #include main() { /* Declare and initialize variables */ double

More information

Introduction to C# Applications

Introduction to C# Applications 1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making

More information

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

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.1 Superior University Department of Electrical Engineering CS-115 Computing Fundamentals Experiment No.1 Introduction of Compiler, Comments, Program Structure, Input Output, Data Types and Arithmetic Operators

More information

C - Basic Introduction

C - Basic Introduction C - Basic Introduction C is a general-purpose high level language that was originally developed by Dennis Ritchie for the UNIX operating system. It was first implemented on the Digital Equipment Corporation

More information

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

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs. I Internal Examination Sept. 2018 Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs. [I]Very short answer questions (Max 40 words). (5 * 2 = 10) 1. What is

More information

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

Unit-II Programming and Problem Solving (BE1/4 CSE-2) Unit-II Programming and Problem Solving (BE1/4 CSE-2) Problem Solving: Algorithm: It is a part of the plan for the computer program. An algorithm is an effective procedure for solving a problem in a finite

More information

Lecture 3 Tao Wang 1

Lecture 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

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space. Chapter 2: Problem Solving Using C++ TRUE/FALSE 1. Modular programs are easier to develop, correct, and modify than programs constructed in some other manner. ANS: T PTS: 1 REF: 45 2. One important requirement

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

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

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics 1 Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-3 2.1 Variables and Assignments 2

More information

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

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

Fundamental of C programming. - Ompal Singh

Fundamental of C programming. - Ompal Singh Fundamental of C programming - Ompal Singh HISTORY OF C LANGUAGE IN 1960 ALGOL BY INTERNATIONAL COMMITTEE. IT WAS TOO GENERAL AND ABSTRUCT. IN 1963 CPL(COMBINED PROGRAMMING LANGUAGE) WAS DEVELOPED AT CAMBRIDGE

More information

1. C++ Overview. C++ Program Structure. Data Types. Assignment Statements. Input/Output Operations. Arithmetic Expressions.

1. C++ Overview. C++ Program Structure. Data Types. Assignment Statements. Input/Output Operations. Arithmetic Expressions. 1. C++ Overview 1. C++ Overview C++ Program Structure. Data Types. Assignment Statements. Input/Output Operations. Arithmetic Expressions. Interactive Mode, Batch Mode and Data Files. Common Programming

More information

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

Introduction of C++ OOP forces us to think in terms of object and the interaction between objects. Introduction of C++ Object Oriented Programming :- An Object Oriented Programming (OOP) is a modular approach which allows the data to be applied within the stipulated area. It also provides reusability

More information

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

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

Introduction to C++ Introduction and History. Characteristics of C++ Introduction and History Introduction to C++ Until 1980, C programming was widely popular, and slowly people started realizing the drawbacks of this language and at the same time, the engineers had come

More information

Programming with C++ Language

Programming with C++ Language Programming with C++ Language Fourth stage Prepared by: Eng. Samir Jasim Ahmed Email: engsamirjasim@yahoo.com Prepared By: Eng. Samir Jasim Page 1 Introduction: Programming languages: A programming language

More information

Chapter 1 Introduction to Computers and C++ Programming

Chapter 1 Introduction to Computers and C++ Programming Chapter 1 Introduction to Computers and C++ Programming 1 Outline 1.1 Introduction 1.2 What is a Computer? 1.3 Computer Organization 1.7 History of C and C++ 1.14 Basics of a Typical C++ Environment 1.20

More information

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

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Introduction to C Programming Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Outline Printing texts Adding 2 integers Comparing 2 integers C.E.,

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Computer System and programming in C

Computer System and programming in C 1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign

More information

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

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

More information

Language Reference Manual

Language Reference Manual TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

Programming in C++ 4. The lexical basis of C++

Programming in C++ 4. The lexical basis of C++ Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++

More information

Programming. C++ Basics

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

Programming for Engineers Introduction to C

Programming for Engineers Introduction to C Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines

More information

CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart Q-2) Explain basic structure of c language Documentation section :

CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart Q-2) Explain basic structure of c language Documentation section : CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart ANS. Flowchart:- A diagrametic reperesentation of program is known as flowchart Symbols Q-2) Explain basic structure of c language

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

More information

Language Fundamentals Summary

Language Fundamentals Summary Language Fundamentals Summary Claudia Niederée, Joachim W. Schmidt, Michael Skusa Software Systems Institute Object-oriented Analysis and Design 1999/2000 c.niederee@tu-harburg.de http://www.sts.tu-harburg.de

More information

Variables and Literals

Variables and Literals C++ By 4 EXAMPLE Variables and Literals Garbage in, garbage out! To understand data processing with C++, you must understand how C++ creates, stores, and manipulates data. This chapter teaches you how

More information

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018 C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR. VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR.  VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS S.LAWRENCE CHRISTOPHER, M.C.A., B.Ed., LECTURER IN COMPUTER SCIENCE PONDICHERRY

More information

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information