Review of C++ Programming PDF

Summary

This document provides a review of C++ programming concepts, including input/output statements, if statements, looping statements, and nested loops. It also covers fundamental topics like character sets, tokens, and data types.

Full Transcript

Review of C++ 1 Programming T he basic concepts of C++ language were Significant Learn...

Review of C++ 1 Programming T he basic concepts of C++ language were Significant Learning Outcomes discussed in Class XI. A good After the completion of this chapter the understanding of these concepts is very learner essential to attain the significant learning outcomes envisaged in the following chapters. uses input statements in programs This chapter is a quick tour to refresh the to enter data into the computer. concepts and skills you acquired in C++ uses output statements in programs language in Class XI. Each concept will be to display various forms of output. presented with necessary details only. The most applies various forms of if important aspects like selection statements and statements to make decisions while looping statements are explained with the help solving problems. of programs. Some advanced features like compares else if ladder and switch nested loops and the effect of break and continue statements in loops are also statement. introduced in this chapter. distinguishes different looping statements of C++. Since we use GNU Compiler Collection (GCC) with Geany IDE for developing C++ programs, selects appropriate loop in we should be aware of the structure of programs for solving problems. program, format of specifying the header file, uses the concept of nested loop in size of the data types, etc. problem solving and predicts the output. 1.1 Basics of C++ identifies the effect of break and C++ being a programming language, we started continue statements in loops by by learning its character set followed by tokens, explaining their effect on the expressions and statements. We also discussed program flow. data types and their modifiers. While constructing expressions, we identified the need of data type conversions. Table 1.1 provides a brief idea of these elements. Computer Applications (Commerce) - XII An overview of C++ Character set Fundamental unit of C++ language. Classified into letters (a - z, A - Z), digits (0 - 9), special characters (# , ; : > { + etc.), white spaces (space bar, tab, new line) and some other characters whose ASCII code fall in the range from 0 to 255. Tokens Basic building blocks of C++ programs. Constituted by one or more characters. Classified into keywords, identifiers, literals, punctuators and operators. Keywords Reserved words that convey specific meaning to the language compiler. Identifiers User-defined words to identify memory locations, statements, functions, data types, etc. Certain rules are to be followed to ensure the validity of identifiers. Identifiers include variables, labels, function names, etc. Literals Tokens that do not change their value during the program run. They are also known as constants. Classified into integer constants, floating point constants, character constants and string constants. Integer constant is constituted by digits only with an optional plus (+) or minus (-) sign as the first character. Floating point constant is expressed in fractional form and exponential form. Character constant is a single character of C++ enclosed within single quotes. There are some special character constants, called escape sequences. They represent some non-printable or non-graphic characters like new line ('\n'), tab space ('\t') and punctuation marks like single quote ('\' '), double quotes ('\"'), question mark ('\?') etc. String constant is a sequence of characters enclosed by a pair of double quotes. Operators Symbols that tell the compiler about some operations. Each of them actually triggers a specific operation. Based on the number of operands (data on which operation is carried out), operators are classified into unary, binary and ternary. Another classification is based on the type of operation 10 1. Review of C++ Programming An overview of C++ performed. They consist of arithmetic (+, -, *, /, %), relational (=, ==, !=) and logical (&&, ||, !) operators. These operators give some value as the result of the operation. There are some special operators named get from (>>) for input, put to (, called extraction operator or get from operator. It is a binary operator and hence it requires two operands. The first operand is the pre-defined identifier cin that identifies keyboard as input object. The second operand is strictly a variable. We can use more than one variable in the same statement to receive more than one input. The following are valid examples: cin>>rad; cin>>a>>b>>c; Output statement To perform output operation, C++ gives the operator

Use Quizgecko on...
Browser
Browser