Java
AWS
C Language

Topics

  • 1. Why is C called a Middle-Level Language?
  • 2. Why is C Considered a Procedural Language? 
  • 3. Difference Between C and C++
  • 4. Why is C Considered Platform Dependent?
  • 5. What is the Basic Structure of a C Program?
  • 7. Why is the main() Function Necessary?
  • 8. Is Multiple main() Allowed in C?
  • 9. What are Preprocessor Directives?
  • 6. What is the Purpose of Header Files?
1. Why is C called a Middle-Level Language?

C is called a middle-level programming language because it combines features of both low-level and high-level languages.

Low-Level Features

These allow C to interact closely with hardware:

  • Direct memory access using pointers

  • Bitwise operations

  • Manual memory management

  • Ability to perform hardware-level programming

  • Used in operating systems and device drivers

High-Level Features

These make programming easier and structured:

  • Functions

  • Arrays

  • Structures

  • Abstraction

  • Structured programming

2. Why is C Considered a Procedural Language? 

C is known as a procedural programming language because it follows a step-by-step procedure to solve a problem.

Key Characteristics

  • Programs are divided into functions (procedures)

  • Focus is on how to perform a task

  • Program execution happens sequentially

  • Uses control statements like if, for, while

  • Follows structured programming

Important Point

C does not support Object-Oriented Programming concepts, such as:

  • Classes

  • Inheritance

  • Polymorphism

  • Encapsulation

3. Difference Between C and C++

Feature C C++
Programming Paradigm Procedural Object-Oriented + Procedural
Data Security Less secure More secure (Encapsulation)
Memory Management Manual (malloc, free) Constructors and Destructors
Function Overloading Not Supported Supported
Inheritance Not Available Available
Polymorphism Not Available Available
Templates Not Available Available

 

4. Why is C Considered Platform Dependent?

C is considered platform dependent because the compiled program depends on the hardware architecture and operating system.

Reasons

1. Machine-Specific Compilation

  • The C compiler converts code into machine-specific assembly and machine code.

  • Different processors (Intel, ARM, etc.) use different instruction sets.

2. OS Dependency

  • A program compiled on Windows may not run directly on Linux or macOS.

3. Data Type Size Differences
The size of data types may vary depending on the system architecture.

Example:

Data Type 32-bit System 64-bit System
int 4 bytes 4 bytes
long 4 bytes 8 bytes
pointer 4 bytes 8 bytes

4. Binary Compatibility

  • Executable files like .exe or a.out are designed for specific operating systems and processors.

5. What is the Basic Structure of a C Program?

A C program follows a specific structure that organizes the code for proper compilation and execution.

Example Program

 
#include <stdio.h>
#define PI 3.14

int main() {
printf("Hello");
return 0;
 

Main Components of a C Program

  1. Header Files

    • Included using #include

    • Provide declarations of library functions

  2. Macros / Preprocessor Directives

    • Defined using #define

    • Used for constants or macro functions

  3. Global Declarations

    • Variables or functions declared outside main()

    • Accessible throughout the program

  4. main() Function

    • The starting point of program execution

  5. Body of the Program

    • Contains statements, loops, conditions, and function calls