History & Classification of Languages; Difference between C and C++
History & Classification of Languages; Difference between C and C++
History & Classification of Languages
Evolution of Programming Languages
Classification of Programming Languages:
1.1 Procedure Oriented Programming (POP)
- FORTRAN is the 1st POP Language
- Examples: C, FORTRAN, PASCAL
- Focus is on
procedures/functions (what to do)
- Global data shared between functions → security risk
- Programs structured as a series of function calls
Problems with POP:
- Global data is accessible to all functions — no data security
- Not
suitable for large, complex programs
- Difficult to model real-world entities
1.2 Object Oriented Programming (OOP)
- Simula is the 1st OOP Language (1960)
- Smalltalk is the **only PURELY OOP
Language**
- C++ is a partial OOP language (also procedural)
- Examples: **C++,
Smalltalk, Java, C#**
- Focus is on objects — data + behavior together
1.3 Object Based Programming
- Ada is the 1st Object Based Language
- Examples: Visual Basic, Ada, Modula-2
-
Has objects but lacks inheritance and polymorphism
1.4 Rule Based Programming
- Examples: PROLOG, LISP
- Used in AI, logic programming
C++ History
Difference between C and C++
C++ Enhancements over C
C++ Input/Output
```cpp
#include
using namespace std;
int main() {
int x;
// cin with extraction operator >>
cout << "Enter a number: "; // cout = console output; << = insertion operator
cin >> x; // cin = console input; >> = extraction operator
cout << "You entered: " << x << endl;
// Multiple inputs
int a, b;
cin >> a >> b;
cout << "Sum: " << a + b << endl;
// String input
string name;
cout << "Enter name: ";
cin >> name; // stops at whitespace
// String with spaces
string fullname;
cout << "Enter full name: ";
getline(cin, fullname); // reads entire line
return 0;
}
```
Continue full topic on App →Practice MCQs (20)
1. In which year was C++ invented?
- A. 1979
- B. 1998
- C. 1972
- D. 1983
2. On which machine did Bjarne Stroustrup originally design C++?
- A. VAX-11
- B. DEC PDP-11
- C. Sun-3
- D. IBM PC
3. Which is the first object-based language?
- A. Modula-2
- B. Ada
- C. None of these
- D. Visual Basic
4. Which of the following is NOT a limitation of C as compared to C++?
- A. Cannot write function inside structure
- B. No data security
- C. Limited re-usability
- D. No support for pointers
5. C++ was restructured / standardised by ANSI in the year __.
- A. 1983
- B. 1981
- C. 1990
- D. 1979
6. ___ is the only language which is purely OOP.
- A. Java
- B. C++
- C. Smalltalk
- D. Simula
7. C++ is developed by ___.
- A. James Gosling
- B. Bjarne Stroustrup
- C. Alan Kay
- D. Brian Kernighan
8. ___ is the first POP (procedure-oriented) language.
- A. C
- B. FORTRAN
- C. BASIC
- D. PASCAL
9. Which name was originally used before the language was named "C++"?
- A. Object C
- B. Enhanced C
- C. Super C
- D. C with Classes
10. How many keywords are available in (unmanaged) C++?
- A. 32
- B. 63
- C. 31
- D. 27
11. Which is the correct difference between `struct` in C and `struct` in C++?
- A. C++ struct supports member functions
- B. In C++, the keyword `struct` is optional when declaring a variable
- C. All of these
- D. C++ struct supports access specifiers
12. In C++ we can declare variables __.
- A. Only at the start of a block
- B. Only globally
- C. Anywhere in a function
- D. Only inside main
13. C++ adds which of the following data types over C?
- A. Both B and C
- B. `bool`
- C. `wchar_t`
- D. None of these
14. Which comment style is introduced by C++ in addition to C?
- A. `/* ... */`
- B. `-- ...`
- C. `# ...`
- D. `// ...`
15. Size of `bool` in C++ is __.
- A. 1 byte
- B. 4 bytes
- C. 1 bit
- D. 2 bytes
16. ___ is the first OOP language (1960).
- A. C++
- B. Smalltalk
- C. Java
- D. Simula
17. Why is a new programming language designed?
- A. Both D and C
- B. None of these
- C. To provide new features
- D. To overcome limitations of older languages
18. Which approach is followed by Procedure-Oriented Programming?
- A. Data-centric
- B. Object-centric
- C. Bottom-up
- D. Top-down
19. Which of the following is NOT an advantage of C?
- A. Portable
- B. Flexible
- C. Object oriented
- D. Efficient
20. Which approach is followed by Object-Oriented Programming?
- A. Linear
- B. Top-down
- C. Bottom-up
- D. Random