Lecture Notes Programming Concepts in C & C++ Kamlesh Tiwari (
[email protected])
1
History
• If we want to use any function we must include the appropriate header file that containes the definitions of that function.
C was originally designed for and implemented on the UNIX operating system on the DEC PDP-11, by Dennis Ritchie. The C language was based on two languages: BCPL, written by Martin Richards, and B, written by Ken Thompson. American National Standards Institute (ANSI) adopted C in 1988.
2
• The definitions of function printf() are found in header file named stdio.h, which is an abbriviation for STanDard Input Output Header file. • To include stdio.h in our program we have to write statement as #include <stdio.h > include statements are written in the begining of the source code, generally before main() function.
Features
C is a general-purpose high-level programming language with features of economy of expression, modern flow control & data structures, and a rich set of operators. it is not specialized to any particular area of application, the absence of restrictions and its generality make it more convenient and effective for many tasks than any other powerful languages. It is not tied to any particular hardware or system, and therefore it is easy to write programs that will run without change on any machine that supports C. It is often called a middle-level computer language because it combines the best elements of high-level languages with the control and flexibility of assembly language.
3
#include<stdio.h> void main() { } What is this void written before the main() ? well it signifies the type of return value from the main() function, for now take it as it is, we will come to it later. • Executable statements are plaved in between the body of main() function, and every executable statement terminates with a semicolon (;) at the end.
First Program
3.2
Let’s start learning by writing the typical Hello program.
Do it
Come let’s write a program that prints Hello. First of all to define precisely output, write Hello as ”Hello”, then use the function printf() to print the output, by • Every C program starts execution form a user depassing ”Hello” to is, as printf(”Hello”). Our executable fined function called main(). this function must be statement is ready present in every C program. Program can have only printf(”Hello”); one main function. Place this statement in the body of main()
3.1
Basics
void main() {
#include<stdio.h> void main() { printf("Hello"); }
} • A function named printf() is used to send output at VDU screen. what we want to print should be placed in between the brackets of printf().
Save this program. what name you want to give this program ? hello.c ok no problem do it. 1
3.3
Compile and Run
were defined by the original version of C, and five more were added by the ANSI C committee: enum, const, signed, void, and volatile.
Next step is to check the output of the program. 3.3.1
Compile
3.3.2
Run
auto break How ? well, press F10, use arrow keys to move to compile case tab, press ENTER, choose the option COMPILE again char press ENTER. const During the compilation the compiler will generate files continue with name hello.bak, hello.map, hello.obj, hello.exe. We default are inerested in hello.exe, this is the executable file for do DOS environment that will give us output.
4.3
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while
Basic Data Type
There are five atomic data types in C, listed below with their size in byte.
How ? well, press F10, use arrow keys to move to run tab, press ENTER, choose the option RUN again press ENTER. The program will get exectued. It prints the desired output to output screen and then, Integrated Development Environment (IDE) of Turbo C start once again.
Type Keyword Size Range valueless void 0 nil character char 1 -128 to 127 integer int 2 -32768 to 32767 floating-point float 4 6 digit precision double floating-point double 8 10 digit precision
To see the output screen press ALT + F5 Congratulation, U done it.
4.4
Modifier of Basic Data Type
Except for type void, the basic data types may have various modifiers preceding them. You use a modifier to alter the meaning of the base type to fit various situa4.1 Identifier tions more precisely. The list of modifiers is as follows : the names of variables, functions, labels, and various signed, unsigned, long, short other user-defined objects are called identifiers. These identifiers can vary from one to several characters. The 4.5 Variables first character must be a letter or an underscore, and subsequent characters must be either letters, digits, or A variable is a named location in memory that is used underscores. to hold a value that may be modified by the program. In C, identifiers may be of any length. However, not all All variables must be declared before they can be used. characters will necessarily be significant. If the identifier The general form of a declaration is. is not used in an external link process, then at least the first 31 characters will be significant. In C++, there is type variable list; no limit to the length of an identifier, and at least the first 1,024 characters are significant. In an identifier, up- Here, type must be a valid data type plus any per and lowercase are treated as distinct. Hence, count, modifiers, and variable list may consist of one or more Count, and COUNT are three separate identifiers. An identifier names separated by commas. Here are some identifier cannot be the same as a keyword, and should declarations: not have the same name as functions that are in the liint i,j,l; brary. short int si; Correct : abcd, Var_2, _env_, envVar unsigned int ui; Incorrect : 1abc, var-2, ab c, this, var...2 double balance, profit, loss;
4
Definitions
Variables will be declared in three basic places: inside functions, in the definition of function parameters, and C has 32 keywords that, combined with the formal C outside of all functions. These are local variables, formal syntax, form the C programming language. Of these, 27 parameters, and global variables.
4.2
Keyword
2
4.6
Access Modifiers
their values between calls.When you apply the static modifier to a local variable, the compiler creates permaThere are two modifiers that control how variables may nent storage for it, much as it creates storage for a global be accessed or modified. These qualifiers are const and variable. The key difference between a static local varivolatile. They must precede the type modifiers and the able and a global variable is that the static local variable type names that they qualify. These modifiers are also remains known only to the block in which it is declared. referred to as cv-qualifiers. In simple terms, a static local variable is a local variable that retains its value between function calls. 4.6.1 const Applying the specifier static to a global variable instructs Variables of type const may not be changed by your the compiler to create a global variable that is known program. (A const variable can be given an initial only to the file in which you declared it. value, however.) The compiler is free to place variables of this type into read-only memory (ROM). For example, 4.7.3 register The register specifier requested that the compiler keep the value of a variable in a register of the CPU rather than in memory, where normal variables are stored. This meant that operations on a register variable could occur much faster than on a normal variable because the register variable was actually held in the CPU and did not require a memory access to determine or modify its value.
const int a=10; creates an integer variable called a, with an initial value of 10 that your program may not modify. Note that a constant must be initialised with value, otherwise the compiler will generate an error. const int a; // is an error
4.7.4 4.6.2
auto
volatile
By default all variables are auto ( if are not static or The modifier volatile tells the compiler that a variable’s register ), they are created on function call and destroyed value may be changed in ways not explicitly specified by on termination of function. Normally we omit the world the program. For example, a global variable’s address auto to declare automatic variable. may be passed to the operating system’s clock routine and used to hold the real time of the system.
5
4.7
Storage Class Specifier
Enclosing character constants in single quotes works for most printing characters. A few, however, such as the carriage return, are impossible to enter into a string from the keyboard. For this reason, C/C++ include the special backslash character constants shown so that you may easily enter these special characters. These are also referred to as Backslash Characters.
There are four storage class specifiers supported by C: extern, static, register, auto 4.7.1
extern
Note that distinction between the declaration and the definition of a variable is that the declaration declares the name and type of a variable, where as a definition causes storage to be allocated for the variable. Because C/C++ allows separate modules of a large program to be separately compiled and linked together, there must be some way of telling all the files about the global variables required by the program. In most cases, variable declarations are also definitions. However, by preceding a variable name with the extern specifier, you can declare a variable without defining it. 4.7.2
Escape Sequences
Code \b \f \n \r \t \" \’ \0 \\ \v \a \? \N \xN
static
Static variables are permanent variables within their own function or file. Unlike global variables, they are not known outside their function or file, but they maintain 3
Meaning Backspace Form feed New line Carriage return Horizontal tab Double quote Single quote Null Backslash Vertical tab Alert (Bell) Question mark Octal constant (N is octal) Hexadecimal constant (N is hexadecimal)
6
Operator
c s f e,E p %
There are four main classes of operators: arithmetic, relational, logical, and bitwise. In addition, there are some special operators for particular tasks. Following is the operator preceding table. Highest
Lowest
( ) [ ] -> . ! ~ ++ (type) * & sizeof * / % + << >> < <= > >= == != & ^ | && || ?: = += -=*= /= etc. ,
7.2
int; single character char *; print string double; [-]m.dddddd, double; [-]m.dddddd[e/E]+/-xx void *; pointer no argument is converted; print a %
scanf
The function scanf is the input analog of printf, providing many of the same conversion facilities in the opposite direction. int scanf(char *format, ...) scanf reads characters from the standard input, interprets them according to the specification in format, and stores the results through the remaining arguments.scanf stops when it exhausts its format string, or when some input fails to match the control specification. It returns as its value the number of successfully matched and assigned input items.
#includ<stdio.h> void main(){ int x; 7 Input Output printf("Enter value :); The ANSI standard defines standard library, and a set scanf("%d",&x); of functions that provide input and output, string hanprintf("You entered %d, it’s double : %d"’,x,2*x); dling, storage management.one of the standard library is } stdio.h. The simplest input mechanism is to read one character at a time from the standard input, normally the keyboard, 8 Statements with getchar char ch= getchar(); In the most general sense, a statement is a part of your In the same way the function int putchar(int) is used for program that can be executed. That is, a statement specoutput: ifies an action. categories of statements are: Selection, putchar(’c’) Iteration, Jump, Label, Expression, Block puts the character c on the standard output, which is by default the screen.
8.1
7.1
printf
C/C++ supports two types of selection statements: if and switch. In addition, the ? operator is an alternative to if in certain circumstances.
The output function printf is used to print some value at screen, the suntax of printf() is int printf(char *format, arg1, arg2, ...); printf converts, formats, and prints its arguments on the standard output under control of the format. It returns the number of characters printed. 7.1.1
8.1.1
if
The general form of the if statement is if (expression) statement; else statement;
Format Specifiers
Character d,i o x,X u
Selection
Argument type; Printed As int; decimal number int; unsigned octal number int; unsigned hexadecimal number int; unsigned decimal number
8.1.2
switch
C/C++ has a built-in multiple-branch selection statement, called switch, which successively tests the value of 4
an expression against a list of integer or character constants. When a match is found, the statements associated with that constant are executed. The general form of the switch statement is switch (expression) { case constant1: statement break; case constant2: statement break; case constant3: statement break; . .. default : statement }
8.2
do-while loop always executes at least once. The general form of the do-while loop is do{ statement; } while(condition);
sequence
8.3
sequence sequence
There are four statements that perform an unconditional branch: return, goto, break, and continue. Of these, you may use return and goto anywhere in your program. You may use the break and continue statements in conjunction with any of the loop statements.
sequence
8.3.1
return
The return statement is used to return from a function. It is categorized as a jump statement because it causes execution to return (jump back) to the point at which the call to the function was made. A return may or may not have a value associated with it. If return has a value associated with it, that value becomes the return value of the function. In C, a non-void function does not technically have to return a value. If no return value is specified, a garbage value is returned. However, in C++, a non-void function must return a value. That is, in C++, if a function is specified as returning a value, any return statement within it must have a value associated with it. (Even in C, if a function is declared as returning a value, it is good practice to actually return one.) The general form of the return statement is
Iteration
iteration statements (also called loops) allow a set of instructions to be executed repeatedly until a certain condition is reached. This condition may be predefined (as in the for loop), or open-ended (as in the while and dowhile loops). 8.2.1
Jump
for
The general design of the for loop is reflected in some form or another in all procedural programming languages. However, in C/C++, it provides unexpected flexibility and power. The general form of the for statement is
return expression;
for(initialization; condition; increment) statement;
8.3.2
goto
Since C/C++ has a rich set of control structures and allows additional control using break and continue, there The general form is is little need for goto. Most programmers’ chief concern about the goto is its tendency to render programs unwhile(condition) statement; readable. Nevertheless, although the goto statement fell out of favor some years ago, it occasionally has its uses. where statement is either an empty statement, a There are no programming situations that require goto. single statement, or a block of statements. The con- Rather, it is a convenience, which, if used wisely, can be dition may be any expression, and true is any nonzero a benefit in a narrow set of programming situations, such value. The loop iterates while the condition is true. as jumping out of a set of deeply nested loops. The goto When the condition becomes false, program control is not used outside of this section. The goto statement passes to the line of code immediately following the requires a label for operation. (A label is a valid identiloop. fier followed by a colon.) Furthermore, the label must be in the same function as the goto that uses ityou cannot jump between functions. The general form of the goto 8.2.3 do while statement is Unlike for and while loops, which test the loop condition at the top of the loop, the do-while loop checks its goto label; condition at the bottom of the loop. This means that a .. 8.2.2
while
5
. label: 8.3.3
of their first element. Therefore, the declared array has 100 elements, balance[0] through balance[99].
9.2
break
C/C++ supports multidimensional arrays. The simplest form of the multidimensional array is the twodimensional array. A two-dimensional array is, essentially, an array of one-dimensional arrays. Syntax to declare a two-dimensional integer array D of size 10,20, is int D[10][20]; To access point 1,12 of array D, you would use D[0][11].
The break statement has two uses. You can use it to terminate a case in the switch statement (covered in the section on switch earlier in this chapter). You can also use it to force immediate termination of a loop, bypassing the normal loop conditional test. When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop. 8.3.4
10
continue
Array
int squire(int x){ int sqr; sqr = x*x; return sqr; } void main(){ int x; x=10; printf("\n Squire of %d is %d",x,squire(x)); }
array is a collection of variables of the same type that are referred to through a common name. A specific element in an array is accessed by an index. In C/C++, all arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. Arrays may have from one to several dimensions. The most common array is the null-terminated string, which is simply an array of characters terminated by a null.
9.1
Functions
In C, a function is equivalent to a subroutine or function in Fortran, or a procedure or function in Pascal. A function provides a convenient way to encapsulate some computation, which can then be used without worrying about its implementation. With properly designed functions, it is possible to ignore how a job is done; knowing what is done is sufficient. C makes the sue of functions easy, convinient and efficient. Let us write a function that calculates squire a integer number.
The continue statement works somewhat like the break statement. Instead of forcing termination, however, continue forces the next iteration of the loop to take place, skipping any code in between. For the for loop, continue causes the conditional test and increment portions of the loop to execute. For the while and do-while loops, program control passes to the conditional tests.
9
Multi Dimension Array
Single Dimension Array 10.1
The general form for declaring a single-dimension array is type var name[size]; Like other variables, arrays must be explicitly declared so that the compiler may allocate space for them in memory. Here, type declares the base type of the array, which is the type of each element in the array, and size defines how many elements the array will hold. For example, to declare a 100-element array called balance of type float, use this statement: float balance[100]; An element is accessed by indexing the array name. This is done by placing the index of the element within square brackets after the name of the array. For example, balance[3] = 12.23; assigns element number 3 in balance the value 12.23. In C/C++, all arrays have 0 as the index
Parameter Passing Mechanicm
In C/C++ we have two parameter passing mechanism, Call By Value and Call By Reference. Call By Value means that the called function is given the values of its arguments in temporary variables rather than the originals,therefore any change maid in the variable value will not effect the original variable. Where as in call by reference the address of the original variable is pssed,therefore any change maid in the variable value will also effect the original variable. // call by value function void fun1(int x){ x=5; }
6
// call by reference void fun2(int &x){ x=15; }
function
name for convenient handling. Structures help to organize complicated data, particularly in large programs, because they permit a group of related variables to be treated as a unit instead of as separate entities. struct student{ char name[30]; char phone[12]; int age,height; float weight };
// call by pointer function // same as call by reference void fun3(int *x){ *x=25; } void main(){ int x; x=10; printf(" %d",x); fun1(x); printf(" %d",x); fun2(x); printf(" %d",x); fun2(&x); printf(" %d",x); }
// // // // // // //
void main(){ student amit; strcpy(amit.name,"Amit"); strcpy(amit.phone,"940123123"); amit.age=19; amit.height=2.3; amit.weight=51;
prints :10 Call by value prints :10 Call by reference prints :15 Call by pointer prints :25
printf(" %d", sizeof(student));// prints:50 }
11.2 10.2
Recurtion
Union
Recurtion is the mechanism by which a function calles itself, it is a very stromg tool in the hands of programmers. By using recurtion complex logic can easily be written. The use of recurtion improves the readability of the program, but the overhead of processor is increased.
A union is a variable that may hold (at different times) objects of different types and sizes, with the compiler keeping track of size and alignment requirements. Unions provide a way to manipulate different kinds of data in a single area of storage, without embedding any machinedependent information in the program.
// recursive function for factorial void fact(int x){ if(x<=1) return 1; return x*fact(x-1); }
union un{ int a; char b; float c; };
// recursive function for fibonnaci series void fibonnaci(int x){ if(x<=2) return 1; return fibonnaci(x-1)+fibonnaci(x-2); }
void main(){ printf(" %d", sizeof(un));// prints:4 }
12
File Handling
void main(){ Let us write a program to open a file report.txt and the printf("\n fact(10) : %d",fact(10)); print it’s contents at screen , as well as copy the contents printf("\n fibonnaci(10) : %d",fibonnaci(10)); in a new file report2.txt. } #include<stdio.h> void main(){ 11 Structure and Union char ch; FILE *fp,*fp2; 11.1 Structure fp =fopen("report.txt" ,"r"); A structure is a collection of one or more variables, posfp2=fopen("report2.txt","w"); sibly of different types, grouped together under a single fread((void*)&ch,1,1,fp); 7
while(!feof(fp)){ printf("%c",ch); fwrite((void*)&ch,1,1,fp2); fread((void*)&ch,1,1,fp); } fclose(fp); fclose(fp2);
int *ptr1,*ptr2; // uninitialized space for 10 element // integer array is created by ptr1=(int*) malloc(10);
}
13
// initialized space for 10 element // integer array is created by ptr2=(int*) calloc(10,sizeof(int));
Pointers
free(ptr1); free(ptr2);
A pointer is a variable that holds a memory address. This address is the location of another object (typically another variable) in memory. If one variable contains the address of another variable, the first variable is said to point to the second one. A pointer declaration consists of a base type, an *, and the variable name. The general form for declaring a pointer variable is type *name; where type is the base type of the pointer and may be any valid type. The name of the pointer variable is specified by name.
}
15
C++
C++ began as an expanded version of C. The C++ extensions were first invented by Bjarne Stroustrup in 1979 at Bell Laboratories in Murray Hill, New Jersey.Most additions made by Stroustrup to C support object-oriented programming, sometimes referred to as OOP.C++’s object-oriented features were inspired by another object-oriented language called Simula67.The first revision of C++ was in 1985 and the second in 1990.The final draft of the C++ standard, by ANSI/ISO was passed out on November 14, 1997.
#include<stdio.h> void main(){ int x=5,y=10; int *ptr; // ptr is a pointer of type int ptr=&x; printf("%d",*ptr);// printf :5
15.1
ptr=&y; printf("%d",*ptr);// printf :10
OOP’S
OOP is a powerful way to approach the job of programming.Object-oriented programming took the best ideas of structured programming and combined them with several new concepts. The result was a dif14 Storage Management ferent way of organizing a program. In the most genThe functions malloc and calloc obtains blocks of eral sense, a program can be organized in one of two ways: around its code (what is happening) or around its memory dynamically. data (who is being affected). Using only structured programming techniques, programs are typically organized void *malloc(size t n) returns a pointer to n bytes of uninitialized storage, or around code. This approach can be thought of as ”code acting on data.” For example, a program written in a NULL if the request cannot be satisfied. structured language such as C is defined by its functions, any of which may operate on any type of data used by void *calloc(size t n, size t size) returns a pointer to enough free space for an array of the program. Object-oriented programs work the other n objects of the specified size, or NULL if the request way around. They are organized around data, with the key principle being ”data controlling access to code.” In cannot be satisfied. The storage is initialized to zero. an object-oriented language, you define the data and the free(p) is the converse of malloc and calloc, it frees routines that are permitted to act on that data. Thus, the space pointed to by it’s parameter p, where p was a data type defines precisely what sort of operations can be applied to that data. originally obtained by a call to malloc or calloc. To support the principles of object-oriented program#include<stdio.h> ming, all OOP languages have three traits in common: void main(){ encapsulation, polymorphism, and inheritance. }
8
15.1.1
Encapsulation
x = length*length ; x += bredth*bredth ; x += height*height ; return pow(x,0.5);
Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. In an object-oriented language, code and data may be combined in such a way that a self-contained ”black box” is created. When code and data are linked together in this fashion, an object is created. In other words, an object is the device that supports encapsulation. Within an object, code, data, or both may be private to that object or public. Private code or data is known to and accessible only by another part of the object. That is, private code or data may not be accessed by a piece of the program that exists outside the object. When code or data is public, other parts of your program may access it even though it is defined within an object. Typically, the public parts of an object are used to provide a controlled interface to the private elements of the object. For all intents and purposes, an object is a variable of a user-defined type. It may seem strange that an object that links both code and data can be thought of as a variable. However, in object-oriented programming, this is precisely the case. Each time you define a new type of object, you are creating a new data type. Each specific instance of this data type is a compound variable.
} }; void main(){ box a(10,20,30); cout<
Inheritance
Inheritance is the process by which one object can acquire the properties of another object. This is important because it supports the concept of classification. If you think about it, most knowledge is made manageable by hierarchical classifications. For example, a Red Delicious apple is part of the classification apple, which in turn is part of the fruit class, which is under the larger class food. Without the use of classifications, each object would have to define explicitly all of its characteristics. However, through the use of classifications, an object need only define those qualities that make it unique within its class. It is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case. As you will see, inheritance is an important aspect of object-oriented programming.
#include
#include<math.h> class box{ private : int length,bredth,height;
class A { public : int l,b;
public: box(int a,int b,int c){ length=a; bredth=b; height=c; }
A(int x,int y){ l=x; b=y; } int area(){ return l*b; } };
int surfaceArea(){ int x; x = length*bredth ; x += length*height ; x += bredth*height ; return 2*x; }
class B : public A { public : int h; B(int x,int y,int z){ A(x,y); h=z; } int surfaceArea() { return 2*(l*l + b*b + h*h); } int volume(){ return l*b*h; } int diagonal() { return pow(l*l + b*b + h*h,0.5); }
int volume(){ return length*bredth*height; } int diagonal(){ int x;
};
9
void main(){ B a(10,20,30); cout<
}
16 16.1
Appendix Algorithms
An algorithm is a finite list of well-defined instructions for accomplishing some task that, given an initial state, will proceed through a well-defined series of successive Object-oriented programming languages support polystates, eventually terminating in an end-state. In other morphism, which is characterized by the phrase ”one worlds we can say it is an ordered sequence of unaminterface, multiple methods.” In simple terms, polymorbiguous and well-defined instructions that performs some phism is the attribute that allows one interface to control task and halts in finite time. access to a general class of actions. The specific action Let’s examine the four parts of this definition more selected is determined by the exact nature of the sitclosely uation. For example, you might have a program that defines three different types of stacks. One stack is used • an ordered sequence means that you can number the for integer values, one for character values, and one for steps floating-point values. Because of polymorphism, you can • unambiguous and well-defined instructions means define one set of names, push() and pop() , that can be that each instruction is clear, do-able, and can be used for all three stacks. In your program you will credone without difficulty ate three specific versions of these functions, one for each type of stack, but names of the functions will be the same. • performs some task The compiler will automatically select the right function • halts in finite time (algorithms terminate!) based upon the data being stored. Thus, the interface to a stackthe functions push() and pop() are the same no there is generally no formal specification to write an algomatter which type of stack is being used. The individual rithm, therefore we can use any language syntax or symversions of these functions define the specific implemenbol to express an algorithm, such an unristricted syntax tations (methods) for each type of data. code is called pseudo code. Many time we say that the Polymorphism helps reduce complexity by allowing the algorithm is written by using pseudo code. same interface to be used to access a general class of actions. It is the compiler’s job to select the specific action (i.e., method) as it applies to each situation. You, the 16.2 Flow Chart programmer, don’t need to do this selection manually. A flowchart is a schematic representation of an algorithm You need only remember and utilize the general inter- or a process. A flowchart is one of the seven basic tools face. The first object-oriented programming languages of quality control, which also includes the histogram, were interpreters, so polymorphism was, of course, sup- Pareto chart, check sheet, control chart, causeandeffect ported at run time. However, C++ is a compiled lan- diagram, and scatter diagram. They are commonly used guage. Therefore, in C++, both run-time and compile- in business/economic presentations to help the audience time polymorphism are supported. visualize the content better, or to find flaws in the pro15.1.3
Polymorphism
cess.
15.2
cin & cout
17
input and Output in C++ is fairly very simple. we use the oblect cout to sent output and cin to read input, library file must be included. consider following example.
References
• Schaum’s Outline of Theory and Problems of Programming with C -by Byron S. Gottfried [TMH] • C++ The Complete Reference - by Herbert Schildt [TMH]
#include void main(){ int x; cout<<"Enter a number :"; cin>> x; cout<<"Double of " <<x <<" is "<< 2*x;
• Let Us C - by Yashavant Kanetkar [BPB] • Prigramming in ANSI C - by E Balagurusamy [TMH]
10