2 Elements Of C

C Programming · Unit 2 · 4 hrs

Elements of C

Exam-focused notes for Elements of C (C Programming, CSC115): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.

What this unit covers

  • C Standards (ANSI C and C99)
  • C Character Set
  • C Tokens
  • Escape sequence
  • Delimiters
  • Variables
  • Data types (Basic, Derived, and User Defined)
  • Structure of a C program
  • Executing a C program
  • Constants/ Literals
  • Expressions
  • Statements and Comments

Constants/ Literals

20795 marks

Differentiate between constant and literals. Why do we need to define the type of data? [5]

--- Basis Constant Literal --------- Definition A constant is a named memory location whose value cannot be changed during program execution. A literal is a fixed, raw value that appears directly in the source code. Has a Name? Yes, it has an identifier/nam...

Full solved answer →

Structure of a C program

20785 marks

Explain structure of a C program with suitable example. [5]

Every C program follows a standard, well-defined structure. Understanding this structure is essential before writing any C program. --- A C program is divided into the following sections: Section Description ------ 1. Documentation Comments describing the p...

Full solved answer →
20755 marks

What is preprocessor directive? Discuss #define derivative with example. [1.5+3.5]

--- A preprocessor directive is an instruction given to the C preprocessor -- a program that processes the source code before actual compilation begins. Preprocessor directives tell the preprocessor to perform specific operations such as file inclusion, mac...

Full solved answer →

Variables

20785 marks

What is variable? How is it different from constant? How do you write comments in C? [1+2+2]

--- Definition (from notes): "Variable is a name that can be used to store values. Variables can take different values but one at a time. These values can be changed during the execution of the program. A data type is associated with each variable." In simp...

Full solved answer →

Data types

20775 marks

What is data type? Why do we need it in programming? Explain any three basic data types with example. [1+1+3]

A data type defines the type of data that a variable can store, the amount of memory it occupies, and the range of values it can hold. In C, there are four fundamental data types: int, char, float, and double. The storage representation of these data types ...

Full solved answer →
20745 marks

What is type conversion? Discuss type casting with suitable example. [5]

Type conversion is the process of converting a value from one data type to another data type. In C, since different variables have different data types (int, float, char, double, etc.), it is sometimes necessary to convert a value of one type into another t...

Full solved answer →