C Programming • C Basics, Operators, Loops
C Programming / šŸ“ Assignment 1 — Unit 1 & Unit 2

šŸ“ Assignment 1 — Unit 1 & Unit 2

Notes 2 C Basics, Operators, Loops

Units Covered: Unit 1 & Unit 2

Notes

šŸ“ ASSIGNMENT 1

Introduction to Computer, Programming & Algorithms + C Basics, Operators & Loops

Units Covered: Unit 1 & Unit 2

Instructions: Answer all questions in detail. Use suitable examples, diagrams, algorithms, flowcharts or C programs wherever required.

Q1. Explain the evolution of computers and describe the major generations of computers.

Explain the concept of computer generations and discuss the major technology used in each generation. Cover the First, Second, Third, Fourth and Fifth Generations of computers.

For each generation, explain its major hardware technology, important characteristics, approximate time period and suitable examples. Also explain how technologies such as vacuum tubes, transistors, integrated circuits and microprocessors contributed to the evolution of computers.

Q2. What is an algorithm? Explain its characteristics and complexity with a suitable example.

Define an algorithm in simple and technical terms. Explain the important characteristics of a good algorithm such as input, output, definiteness, finiteness and effectiveness.

Explain the concept of time complexity and space complexity and introduce the basic complexity notations O(1), O(n) and O(n²) with suitable examples.

Finally, write an algorithm to find the largest of three numbers and explain the steps of your algorithm.

Q3. Explain the basic structure of a C program and the role of C tokens and data types.

Describe the general structure of a C program and explain the purpose of important sections such as preprocessor directives, the main() function, variable declarations, statements and the return statement.

Explain C tokens and discuss the major categories of tokens: keywords, identifiers, constants, string literals, operators and special symbols or punctuators with suitable examples.

Also explain basic data types in C such as int, char, float and double with suitable examples.

Q4. Explain C operators and precedence with suitable examples.

Explain the major types of operators used in C, including arithmetic, relational, logical, assignment, increment/decrement and conditional operators.

Explain operator precedence and associativity and describe why they are important when multiple operators are used in an expression.

Evaluate the following expressions and explain the order in which the operators are applied:

int a = 10, b = 5, c = 2;

int x = a + b * c;
int y = (a + b) * c;
int z = a > b && b > c;

Also explain how the use of parentheses can change the result of an expression.

Q5. Explain control structures in C and differentiate between selection and looping statements.

Explain the concept of control structures and why they are required in programming. Discuss if, if-else, nested if, switch-case, while, do-while, for, break and continue with suitable examples.

Clearly differentiate between selection statements, looping statements and unconditional control statements.

Finally, write a C program using nested if to find the largest of three numbers and explain how the control flows through the program.