PASSING PACKAGE — MODULE 1
Programming in C (1BEIT205) — VTU 2025 Scheme
City Engineering College, Bengaluru | Dept. of AIML/ISE
Q1. What is Computing and Computer Language? Explain the types of computer
languages with examples.
Computing is the process of using computers to perform tasks like calculations, data processing, and
problem solving. A computer language is a set of instructions used to communicate with a computer.
Computers understand only binary (0s and 1s), so programmers write code in languages that are later
translated into machine code.
Computer languages are divided into three levels:
• Machine Language – Lowest level, uses only 0s and 1s, directly understood by the CPU. Fast
execution, no translator needed, but very hard to read/write and not portable.
• Assembly Language – Uses mnemonics (symbolic names) like MOV, ADD, SUB instead of
binary. Easier than machine language but still needs an assembler to convert it to machine code.
• High-Level Language – Written using English-like words and symbols (e.g., C, Java, Python).
Easy to read, write, and is machine-independent, but needs a compiler/interpreter to run.
Final Answer: Computing is using computers to solve problems; computer languages are classified into
Machine, Assembly, and High-Level languages, increasing in readability and decreasing in execution
speed.
Q2. Describe C. Explain the History of C.
C is a general-purpose, middle-level, structured/procedural programming language developed by
Dennis Ritchie in 1972 at Bell Laboratories. It is called middle-level because it supports both high-level
features (functions) and low-level features (pointers).
History (key points):
• C evolved from a language called BCPL (by Martin Richards), which influenced B (by Ken
Thompson).
• B led to the development of C in the early 1970s, first implemented on a DEC PDP-11 system.
• In 1983, ANSI formed a committee to standardize C. The standard ANSI C (C89) was completed in
1989.
• ISO later adopted the same standard, calling it ANSI/ISO C.
• In 1999, C99 was released, adding features like Variable Length Arrays and the restrict keyword,
while keeping the core of C89 unchanged.
Final Answer: C is a middle-level structured language created by Dennis Ritchie (1972) at Bell Labs,
standardized as ANSI C in 1989 and later updated as C99 in 1999.
Q3. Describe the general form (structure) of a C program with a suitable example.
A C program is divided into sections, each with a specific purpose, which makes it easy for the compiler
to understand and for programmers to read/maintain:
• Documentation Section – Comments describing program name, author, purpose (not executed).
• Link Section – Includes header files using #include (e.g., stdio.h) for predefined functions.
• Definition Section – Defines constants using #define.
• Global Declaration Section – Variables/functions declared outside main(), accessible
everywhere.
• main() Function Section – Execution starts here; contains declarations and executable
statements.
• Subprogram Section – Contains user-defined functions called from main().
Example:
#include<stdio.h>
int main()
{
int x, y, z;
printf("Enter any two numbers: ");
scanf("%d%d", &x, &y);
z = x + y;
printf("Sum = %d", z);
return 0;
}
Final Answer: A C program has 6 sections — Documentation, Link, Definition, Global Declaration,
main(), and Subprogram — executed starting from main().
Q4. Explain the System Development Life Cycle (SDLC).
SDLC is the process of creating computer-based solutions to real-world problems, done in phases:
• Problem Definition / Planning – Identify the problem, decide what/why/cost/time of the project.
• System Analysis – Gather requirements; understand what the system should do.
• System Design – Prepare blueprints like data flow diagrams and algorithms.
• Implementation – Actual coding using a language like C.
• Testing – Find and fix logical, syntax, and runtime errors.
• Deployment – Install and configure the system for users.
• Maintenance – Update/enhance the system based on feedback.
Final Answer: SDLC has 7 phases — Planning, Analysis, Design, Implementation, Testing,
Deployment, and Maintenance — followed in order to build a reliable system.
Q5. Define data type. Mention its types. Explain primitive data types in C with examples.
A data type specifies the type of data a variable can hold, the memory it occupies, and the range of
values it can store.
Types of data types: Basic (int, float, double, char, void), Derived (array, pointer, function), and
User-defined (structure, union, enum).
Primitive (Basic) Data Types:
Data Type Use Memory Example
int Whole numbers 2 or 4 bytes int count = 10;
float Decimal numbers 4 bytes float pct = 85.5;
double Large decimals, more accuracy 8 bytes double d = 1234.5678;
char Single character 1 byte char grade = 'A';
void No value (used in functions) — void display();
Final Answer: Data types are Basic, Derived, and User-defined. The 5 primitive types in C are int, float,
double, char, and void.
Q6. What is a variable? Explain the rules to construct variables. Classify the given
identifiers as valid/invalid.
A variable is a name given to a memory location where data can be stored and accessed.
Rules for naming a variable:
• Must start with a letter (A–Z, a–z) or an underscore (_).
• Can be followed by letters, digits (0–9), or underscores.
• No special symbols (like $, +, #, -) are allowed.
• Cannot be a C keyword (e.g., for, int, while).
Classification of given identifiers:
Identifier Valid / Invalid Reason
num2 Valid Starts with a letter, followed by a digit
$num1 Invalid Cannot start with $
+add Invalid Cannot start with +
a_2 Valid Starts with letter, has underscore and digit
199_space Invalid Cannot start with a digit
_apple Valid Can start with underscore
#12 Invalid Cannot start with # or a digit
Final Answer: A variable name must start with a letter/underscore and contain only letters, digits,
underscores — never a keyword. Valid: num2, a_2, _apple. Invalid: $num1, +add, 199_space, #12.
Q7. Develop a C program which takes P, T, R as input and calculates Simple Interest.
#include <stdio.h>
int main() {
float P, T, R, SI;
printf("Enter Principal (P): ");
scanf("%f", &P);
printf("Enter Time (T): ");
scanf("%f", &T);
printf("Enter Rate (R): ");
scanf("%f", &R);
SI = (P * T * R) / 100;
printf("Simple Interest = %.2f\n", SI);
return 0;
}
Sample Input: P = 10000, T = 2, R = 5
Final Answer: Output → Simple Interest = 1000.00 (using formula SI = P×T×R/100).
Q8. Differentiate between (I) Linker and Loader (II) Compiler and Interpreter.
(I) Linker vs Loader:
• Linker – Combines the user-written code with library/object code to produce one executable file.
• Loader – Loads this executable file into main memory and prepares it for execution by the CPU.
(II) Compiler vs Interpreter:
Aspect Compiler Interpreter
Translation Whole program at once Line by line
Speed Faster after compiling Slower (runtime translation)
Errors Shown after full compilation Shown immediately per line
Output file Produces .exe file No separate file
Examples C, C++ Python, JavaScript
Final Answer: Linker creates the executable by combining object code; Loader loads it into memory to
run. A compiler translates the whole program at once, while an interpreter translates and executes line
by line.
Q8.1 Develop a C program to multiply, subtract, and divide two whole numbers (choose
suitable data types).
#include <stdio.h>
int main() {
int a, b, diff, product;
float division;
printf("Enter two whole numbers: ");
scanf("%d %d", &a, &b);
diff = a - b;
product = a * b;
division = (float)a / b;
printf("Subtraction = %d\n", diff);
printf("Multiplication = %d\n", product);
printf("Division = %.2f\n", division);
return 0;
}
Sample Input: 10 2 → Output: Subtraction = 8, Multiplication = 20, Division = 5.00
Final Answer: int is used for whole numbers and float for division (to retain decimal accuracy).
Type-casting (float)a is needed before dividing two integers.