Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What are some other programming languages besides C++? How do they compare to

ID: 3661649 • Letter: 1

Question

1. What are some other programming languages besides C++? How do they compare to C++?

2. C++ is a superset of the C programming language. C itself is a descendant of several generations of early languages; it was created and implemented with conflicting goals in mind. This is why C++ contains features that are inconsistent and sometimes irritating. What are the major characteristics of C? How does C++ use this "inheritance" to achieve its goals?

3. With functional programming, it is not easy to make sure that all functions that access or modify particular data are listed in the same place. How did the object-oriented approach resolve this problem?

4. In object-oriented programming, we design a program as a set of cooperating objects rather than as a set of cooperating functions. What is a class? What is an object? What are their relationships? What are the advantages of using objects?

Explanation / Answer

1. What are some other programming languages besides C++? How do they compare to C++?

Charles Babbage Invented the Analytical Engine. His companion, Ada Augusta Lovelace, is considered the first

programmer in history.

The following are Programming anguages

   1.Fortran
   2.Algol 60
   3.Cobol
   4.PL/I
   5.Basic
   6.Simula 67
   7.Algol 68
   8.Pascal
   9.Ada
   10.C
   11.Lisp
   12.Smalltalk
   13.C++
   14.Java

The following are Scripting languages
   scripting languages are classified by two categories,they are
1.Text processing:
Perl
Python
2.Web programming
JavaScript
PHP

Languages that merge programming and are compared as follows:

1.Object-oriented extensions: not only C++,but also Lisp or Prolog (XPCE/Prolog, Prolog++).

2.Logic programming combined with functional programming (very clever, but only experimental).

3.Most languages are sequential: one processor,one process.Ada is a language designed to support concurrency

i.e processes running in parallel.

4.Java uses a singly-rooted hierarchy, so all objects are ultimately inherited from the root class Object.

5.Java contains standard libraries for solving specific tasks. C++ relies on non-standard third-party libraries.

6.Although they look similar, arrays have a very different structure and behavior in Java than they do in C++.

7.There are no Java pointers in the sense of C and C++

8.All the primitive types in Java have specified sizes that are machine independent for portability.

9. Java when compare with c++ it has no preprocessor and everything must be in a class.

10. Type-checking and type requirements are much tighter in Java when compared with c++.

2. C++ is a superset of the C programming language. C itself is a descendant of several generations of early languages; it was created and implemented with conflicting goals in mind. This is why C++ contains features that are inconsistent and sometimes irritating. What are the major characteristics of C? How does C++ use this "inheritance" to achieve its goals?

The following are the major C characteristics:
   1.low-level assembly language and a high-level programming language like Java

2.C is not object oriented Can’t “hide” data as “private” or “protected” fields

3.C has portability issues i.e Low-level “tricks” may make your C code run well on one platform

4.The compiler and runtime system will rarely stop your C program from doing stupid/bad things

5.Compile-time type checking is weak No run-time checks for array bounds errors, etc. like in Java

C++ was designed to provide Simula’s facilities for program organization together with C’s efficiency and flexibility

for systems programming.

Classes

User-defined types

Operator overloading

References

Pass-by-reference function arguments

Virtual Functions

Dispatched depending on type at run time

Templates

Macro-like polymorphism for containers (e.g., arrays)

Exceptions

Function Overloading

Implementing Inheritance

Default arguments

Multiple Inheritance

Inherit from two or more classes

In Single inheritance,More compact way to write larger structures where as in Function name overloading

Completely resolved at compile time

Namespaces are Completely resolved at compile time

3. With functional programming, it is not easy to make sure that all functions that access or modify particular data are listed in the same place. How did the object-oriented approach resolve this problem?

Steps To Create A File

1. Declare an object of the desired file stream class(ifstream, ofstream, or fstream)

2. Open the required file to be processed using constructor or open function.

3. Process the file.

4. Close the file stream using the object of file stream

File TYPES

A File can be stored in two ways
1.Text File
2.Binary File

1.Text Files : Stores information in ASCII characters. In text file each line of text is terminated by with special

character known as EOL (End of Line) In text file some translations takes place when this EOL character is read or

written.

2.Binary File: it contains the information in the same format as it is held in the memory. In binary file there is no

delimiter for a line. Also no translation occur in binary file. As a result binary files are faster and easier for program

to read and write

Closing a File

A File is closed by disconnecting it with the stream it is associated with. The close( ) function is used to accomplish this task.
Syntax: Stream_object.close( );
Example : fout.close();

FEATURES OF OBJECT ORIENTED LANGUAGE      

8. Follows bottom-up approach in program design

4. In object-oriented programming, we design a program as a set of cooperating objects rather than as a set of cooperating functions. What is a class? What is an object? What are their relationships? What are the advantages of using objects?

CLASSES AND OBJECTS

Class: class is a user defined data type that represents an entity, which is a collection of members and methods.

The entire set of data and code of an object can be made the user define data type with help of a class. Infact

objects are variables of type class. Once a class has been defined, we can create any number of objects belonging

to that class.

Syntax:       class_class name

                    {

                    access specifier/visibility mode:

variable declarations/data members;

access specifier/visibility mode:

function declarations/member functions;

}

The keyword class specifies that what follows is abstract data of type class.The class body contains the declarations of variables and functions, which are called as class members. The variables declare inside the class are known as data members and functions are known as member functions.

C++ supports three types’ access specifiers

a) Public

b) Private

c) Protected

These three keywords are also known as visibility modes.

Public: It indicates the accessibility of a member to the outside class i.e., the data members can be accessed by any function from the outside. These members are used to provide an interface for the outside classes.

Private: The members can be accessed only by the member functions. The class members that have been declared as private can accessed only from within the class. By default, the members of class are private. Data hiding is possible with the help of private keyword.

Protected: The member data can be accessed by member functions of that class. The member is also accessible to member functions and the friend functions that are derived from this class. But they are not available to any one of the outside function. This specifier is most recently in the concept of Inheritance

Object: is a functionable element that is used to access the members and methods of a class. Simply, object is an instance of class.

Example Program on Class and Object

#include<iostream.h>

#include<conio.h>

class examp

{

int a,b,t;

public:

void getdata();

void swap();

void disp();

};

void examp::getdata()

{

cout<<"enter a and b values"<<endl;

cin>>a>>b;

}

void examp::swap()

{

t=a;

a=b;

b=t;

}

void examp::disp()

{

cout<<"After swapping";

cout<<a<<" "<<b;

}

void main()

{

examp e;

clrscr();

e.getdata();

e.swap();

e.disp();

getch();

}

Output:

enter a and b values

2 3

After swapping     3 2