MCS-201 · Unit 1

Programming Fundamentals

Section 7 of 9

Block 1 · Unit 1Programming Fundamentals11 min · Section 7 of 9

1.7Features of C and the Structure of a C Program

Covers IGNOU MCS-201 §1.6.2, 1.7

C is small, fast and close to the hardware, yet portable and structured. These features explain why it is still used for operating systems and embedded devices. This section lists them, then shows the standard layout that every C program follows.

Salient features of C

FeatureMeaningExample
Middle-levelHigh-level syntax with low-level access to memory and bitsPointers (Unit 7), bitwise operators
StructuredBuilt from functions and the three control structuresEvery program is a set of functions starting with main
PortableThe same source code can be compiled on different machinesOne .c file compiled for x86 and for ARM
EfficientTranslates closely to machine code, so programs are fast and smallOperating system kernels, device firmware
Small coreOnly 32 keywords in C89; most facilities come from librariesprintf is a library function, not a keyword
Rich standard libraryReady-made functions for common tasksprintf, strlen, sqrt
ExtensibleProgrammers add their own functions and librariesA calcPercentage function
Case-sensitiveUpper-case and lower-case letters are differentsum, Sum and SUM are three names

C is often called a middle-level language because it combines the features of high-level languages (functions, control structures, portable source code) with the hardware access of low-level languages (pointers holding memory addresses, operators that work on individual bits).

Structure of a C program

The function is the basic unit of a C program. Every program is a collection of functions, and exactly one of them must be called main.

SectionRequired?Purpose
Documentation (comments)No, but good practiceExplains the program; ignored by the compiler
Preprocessor directivesAlmost alwaysLines starting with #, handled before compilation, such as #include and #define
Global declarationsNoVariables and function prototypes visible to every function
main functionYes, exactly oneThe entry point: execution starts here
User-defined functionsNoThe sub-tasks from top-down design

Other rules: every statement ends with a semicolon ;, and braces { } group statements into a block, such as the body of a function.

Key takeaways

  • C is called middle-level because it joins high-level structure with low-level hardware access.
  • Only C source code is portable; executables must be rebuilt for each processor.
  • A C program has documentation, preprocessor directives, global declarations, main and user-defined functions.
  • The function is the basic unit; execution starts at main.

Practice questions

Answer on paper first, then check. The explanation matters more than the letter you chose.

Question 1 · multiple choice

What is the basic unit of a C program?

Show answer

Answer: C. A function

C programs are collections of functions, and execution begins in main. Statements live inside functions, so they are not the basic unit.

Question 2 · multiple choice

Why is C called a middle-level language?

Show answer

Answer: A. It combines high-level features such as functions with low-level features such as pointers and bit operations

The term refers to C’s mix of high-level structure and low-level hardware access. C is fully compiled, not partly interpreted.

Question 3 · multiple choice

Which part of a C program is compulsory?

Show answer

Answer: D. The main function

Every program needs exactly one main, where execution starts. Comments and global declarations are optional.

Question 4 · multiple choice

What does this program print?

C · q4.c
#include <stdio.h>

int main(void)
{
    printf("C was born in %d\n", 1970 + 2);
    return 0;
}
Show answer

Answer: C. C was born in 1972

%d is replaced by the value of the integer expression 1970 + 2, which is 1972. The text inside the quotes is printed, but the format specifier is substituted.

Question 5 · multiple choice

A program declares variables total and Total. What happens?

Show answer

Answer: B. They are two different variables

C is case-sensitive, so total and Total are different names. A duplicate-name error would only occur if the spelling, including case, were identical.

Question 6 · short answer

Explain why C is called a middle-level language, giving one example feature from each side.

Show worked answer

C is called a middle-level language because it combines the features of high-level languages with the hardware access of low-level languages. On the high-level side it has functions, control structures such as if and while, and portable source code; for example, if (marks >= 40) printf("Pass"); reads almost like English. On the low-level side it has pointers, which hold memory addresses, such as int *p = &x;, and bitwise operators, which work on individual bits, such as flags & 1.

↑ ↓ move↵ openTab switch type