ar
Feedback
AFRICA CODER

AFRICA CODER

الذهاب إلى القناة على Telegram

We are helping you to learn programming We provide Short Notes, video, and also pdf of Programming Languages Join Our Group And Subscribe For more info. We grow up together!! for any suggestion contact me👉 @bluefannn

إظهار المزيد
770
المشتركون
لا توجد بيانات24 ساعات
لا توجد بيانات7 أيام
لا توجد بيانات30 أيام
أرشيف المشاركات
Return Statement When the program flow reaches a return statement or the end of a function code block, it branches back to the function that called it. If the function is any type other than void, the return statement will also cause the function to return a value to the function that called it. Syntax: return [expression] If expression is supplied, the value of the expression will be the return value. If the type of this value does not correspond to the function type, the function type is con￾verted, where possible. However, functions should always be written with the return value matching the function type. The function area() makes use of the fact that the return statement can contain any expression. The return expression is normally placed in parentheses if it contains operators. If the expression in the return statement, or the return statement itself, is miss￾ing, the return value of the function is undefined and the function type must be void. Functions of the void type, such as the standard function srand(), will perform an action but not return any value

■ Macros: A macro definition must be visible to the compiler. The substitute text is inserted and re-compiled each time the macro is called. For this reason, a macro should contain only a few statements to avoid inflating the object file each time the macro is called. The speed of program execution will, however, improve since the program does not need to branch to sub-routines in contrast to normal func￾tion calls. This can become apparent when macros are used within loops, for example. Side effects of macros are possible if the substitute text contains multiple instances of a parameter. The statement SQUARE( ++x ) expands to ((++x) * (++x)), for example. The variable x is incremented twice and the product does not represent the square of the incremented number. ■ Functions: Functions are compiled independently. The linker then links them into the executable file. The program branches to the function whenever it is called, and this can reduce the speed of execution in comparison to a macro. However, the executable file will be shorter as it contains only one instance of the function code. The compiler checks the argument types, and the side effects seen with macros cannot occur @Ethiopian programmer😊

Conditional Operator The conditional operator ?: is used to form an expression that produces either of two values, depending on the value of some condition. Because the value produced by such an expression depends on the value of a condition, it is called conditional expression. In contrast to the if-else statement the selection mechanism is based on expres￾sions: one of two possible expressions is selected. Thus, a conditional expression is often a concise alternative to an if-else statement. Syntax: expression ? expression1 : expression2 expression is evaluated first. If the result is true, expression1 is evaluated; if not expression2 is executed. The value of the conditional expression is therefore either the value of expression1 or expression2. Example: z = (a >= 0) ? a : -a; This statement assigns the absolute value of a to the variable z. If a has a positive value of 12, the number 12 is assigned to z. But if a has a negative value, for example –8, the number 8 is assigned to z. Since this sample program stores the value of the conditional expression in the vari￾able z, the statement is equivalent to if( a > 0 ) z = a; else z = -a; Precedence The conditional operator is the only C++ operator with three operands. Its precedence is higher than that of the comma and assignment operators but lower than all other opera￾tors. In other words, you could omit the brackets in the first example. You can use the result of a conditional evaluation without assigning it, as the sample program on the opposite page shows. In this example, x is printed on screen if x is greater than y, and y is printed otherwise. However, you should assign the result of complex expressions to a variable explicitly to improve the readability of your program. @Ethiopian programmer 😊🙏

Header files of the C++ standard library Header files of the C standard library algorithm ios map stack bitset iosfwd memory stdexcept complex iostream new streambuf dequeue istream numeric string exception iterator ostream typeinfo fstream limits queue utility functional list set valarray iomanip locale sstream vector

photo content
+6

photo content
+8

photo content
+9