Corrections in CS201 Handouts

Page No. 15

The old-style C++ header files are written with .h such as iostream.hwhereasnew-style header filenames omit the “.h” suffix such as iostream. Some headers, such as math.h, were inherited from the C language. In those cases, the new-style headers prefix a “c” to the name and omit the “.h”. It is better to use new-style headers (vector, string, etc). For C library, new-style headers start with ”c” (cstdio, cstdlib, etc).
The new style C++ header files are all wrapped in a single namespace called std. The namespace std contains entire C++ standard library. The using namespace is used to import entire std namespace into current scope so that items within namespace can be used in program.
Old style:
#include<iostream.h>
New style:
using namespace std ;
#include<iostream>

Newer version of Dev-C++ supports new style of including header file so it is better to use new style.

Page No. 18

While using old style of including header file, following warnings at the bottom of Dev-C++ will appear. It is just a warning and not a syntax error. You can ignore this warning and run your program. It will run successfully. You can avoid this warning by using new style of header files instead of old style with .h extension.

Page No. 84, 85, 129, 133, 139, 173, 178, 353, 380, 462, 483

In Dev C++, main function must return a value. Dev-C++ does not allow void main() so int main() or main() will be used while using Dev-C++. Both int main() and main() are similar.If we do not mention return value type with function name then default return type of such function will be int.

Page No.29

In the topic Use of Operators, problem statement is incorrect.

Error:

Write a program that takes a four digits integer from user and shows the digits on the screen separately i.e. if user enters 7531, it displays 7,5,3,1 separately.

Correction:

Write a program that takes a four digits integer from user and shows the digits on the screen separately i.e. if user enters 7531, it displays 1,3,5,7 separately.

Page No. 95

In the topicFunction Calling,program contains error.

Error:

Function prototype should contain asterisk “*’.

Correction:

#include <iostream.h>

void square(double *);

main()

{

…..}

Page No. 104-105

In the topicSample Program 1,program contains error.

Error:

Program also accept the negative inputs, program output should be as follows,

Correction:

The total number of integers entered by user is

Page No. 418

Overloading [] operator to create arrays

if( (index = 0) &

(index < length) )

return aray[index];

Error:

If condition should be like follows.

Correction:

if( (index >= 0) &

(index < length) )