COMP 103
Structured Programming
GE/CHEM/ENE/EE
Assignment Set #0
1. What is a computer program?
2. Define software and explain the different types of software.
3. Explain what a programming language is and why it is needed? What are the different types of
programming language, explain about structured or procedural programming language.
4. Draw a timeline and write in brief about the history of computing by describing the different
technologies used in each generation.
5. What are computer peripherals? Explain the various types with common examples.
6. Enumerate and explain the different stages in the software development lifecycle (SDLC).
7. Write briefly about the contribution of the following people in the field of computing
a. Charles Babbage
b. Lady Ada Lovelace
c. Tim Berners Lee
d. Dennis Ritchie
e. Alan Turning
8. Write short notes (about 50 words) on the following topic
a. Abacus
b. Pascal’s Calculator
c. Punched Cards
d. Vacuum Tubes
e. ENIAC
f. Transistors and CMOS
g. CPU
h. ALU
i. RAM
9. You may have noticed that we use the Linux operating system in our labs. Explore briefly about it
and write your findings.
10. Write complete step-by-step instruction on how to create, compile and run the “hello world” C
program. Anyone with no prior experience should be able to understand and follow your
instructions.
Assignment Set #1
1. What is the C character set and what is meant by C Tokens?
2. Define the terms initialization, declaration and assignment and illustrate with examples in C.
3. Differentiate between keywords and identifiers in C. What are the rules and conventions for
naming identifiers?
4. What are variables and constants in C? How are the defined?
5. What are the different data types available in C and what type of values are they used to store?
Give examples with their size and range of values. Also differentiate what is means to be signed
and unsigned.
6. Define operators and operands? Classify operators based on the number of operands and give
example of each.
7. What do you mean by precedence and associativity? Make a table with operators in decreasing
order of precedence and state their associativity in a separate column.
8. Write about each with example:
a. Arithmetic Operators
b. Unary Operators
c. Tertiary Operator
d. Relational and Logical Operators
e. Assignment Operators
f. Conditional Operators
9. What is meant by decision control statement? Write about each of these by mentioning appropriate
conditions to use them in and give code examples.
a. if-else
b. nested if-else
c. else-if ladder
d. switch (and default keyword)
10. What is meant by loop control statement? Write about each of these by mentioning appropriate
conditions to use them in and give code examples.
a. while
b. do-while
c. for
d. break
e. continue
Assignment Set #2
1. What is a function? How can you define, declare and use it in your code?
2. Explain the role of five main features of a function? [Data Type, Return Value, Name, Arguments,
Body]
3. What three types of errors do function-prototypes help prevent?
4. State at least three advantages of making your program modular using functions.
5. What is meant by the scope and lifetime of a variable within a program? How do they differ?
6. Differentiate between Library Functions and User Defined Functions with Examples.
7. What is meant by call by value? Explain with code example.
8. What is meant by call by reference? Explain with code example.
9. What is Recursion? What conditions must a function satisfy to be recursive?
10. What advantages/disadvantages of using recursive functions?
Assignment Set #3
1. What are arrays? How can you declare and use them in your program?
2. In what way does an array differ from an ordinary variable?
3. How are elements of an array indexed? How can we know the end of an array?
4. How can an array used to store a string?
5. How can you pass an array into a function?
6. What is a 2D (Two Dimensional) array? How can you index a particular location in a 2D array?
7. In what cases would you rather use a 2D array? Give code example.
Assignment Set #4
1. How are variables addressed in the computer memory?
2. What is a pointer variable? What are the advantages of using a pointer?
3. What is the difference between array and pointer variable? In what way are they similar?
4. What is a structure? How is it different from union?
5. Explain the use of sizeof() operator.
Assignment Set #5
1. What is meant by Dynamic Memory Allocation (DMA)?
2. What are the advantages and disadvantages of using DMA?
3. How can you use DMA in your program?
4. Explain the use of the following terms:
a. malloc
b. calloc
c. realloc
d. free
5. What happens when you forget to free memory?
LAB 1: Operators and Expressions
1. Write a program to convert Centigrade to Fahrenheit. [F = 9/5 * C + 32]
2. Write a program that calculates the area and circumference of a circle.
3. Write a program that calculates the area of a triangle.
4. Write a program that reads the marks in 5 subjects and calculates their percentage.
5. Think of an interesting problem and prepare a solution for that problem.
LAB 2: Control Statements
1. Write a program that reads a number and identifies whether the given number is even or odd.
2. Write a program to find the largest number among three numbers.
3. Write a program to print day from its numeric position in the week. [1: Sunday … 7:
Saturday] (use Switch statement)
4. Write a program to read the grade of a subject and prints the equivalent marks range. (use
Switch statement)
5. Write a program to solve your own problem. [Use Logical Operators]
LAB 3: Looping
1. Write a program to generate the pattern using for loop
a
aa
aaa
aaaa
aaaaa
2. Write a program to generate Fibonacci number using do while loop. [Xn = Xn-1 + Xn-2]
3. Write a program to read number and identifies whether the given number is a prime number
or not.
4. Write a program to read a sentence and counts the total number of character using while loop.
5. Solve your own questions using loops.
LAB 4: Functions
1. Write a program to identify whether the given number is a perfect number or not using a
function. [A number that is the sum of its factorials. 6, 28 are examples of perfect numbers]
2. Write a program to evaluate GCD of two given integers. Use function that returns GCD.
3. Write a C program that reads three coefficients a, b and c for quadratic equation and finds
whether the solutions are in real or imaginary. [ax2 + bx + c = 0 if b2-4ac >=0 then the
solutions are real.]
LAB 5: Recursion
1. Write a recursive program to find the factorial of a given number.
2. Write a recursive program to find a GCD of two numbers.
3. Write a recursive program to find the sum of n natural numbers.
LAB 6: Array
1. Write a C program to store N numbers in a one dimensional array and calculate its average
with the help of the function.
2. Write a C program to convert a binary number to decimal with the help of the function.
LAB 7: 2D Array
1. Write a program to evaluate transpose of n by n matrix with the help of function.
2. Write a C program for matrix addition with the help of function.
3. Write a C program to determine determinant of a square matrix with the help of function.
LAB 8: Sorting
1. Write a program to arrange the numbers (array) in ascending order using bubble sort.
2. [Optional] Try selection sort on your own.
LAB 9: Structures
1. Write a program that defines a structure called STUDENT with suitable attributes and reads
the data for 5 students. Your program should display the records in ascending order according
to the name of the students.
2. Consider a plane graph. Write a program that uses function to return a distance
between given point and the origin.
LAB 10: Pointers
1. Write a program that swaps two variables. Use function and pointers.
2. Solve the matrix multiplication problem using pointers.
Extra instruction for the course:
Refer to the syllabus and go through the mentioned topics
Syllabus: [[Link] [Link]]
1. Textbooks:
a) Byron s. Gottfried, “Theory and Problems of Programming with C, 2/e”, McGraw- Hill.
b) Robert L Wood, “C Programming for Scientists and Engineers”, Penton Press.
2. Reference Books:
a) “Let Us C” by Yashwant Kanetkar
b) “The C Programming Language” by Balaguruswamy
3. Instructional Links (just for reference):
a) C Programming Tutorials by the newboston on youtube
[[Link]
b) C Tutorial by tutorialspoint
[[Link]