C Programming Assignment 2: Squares, Loops, Functions, and Arrays, Exercises of Computer Programming

An assignment for a c programming course, covering topics such as printing the squares of numbers, do-while and while loops, break and continue statements, functions, return statements, pre-processor directives, and arrays. Students are expected to write programs to complete the tasks and understand the concepts.

Typology: Exercises

2011/2012

Uploaded on 07/19/2012

anandi
anandi 🇮🇳

4.5

(8)

61 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT No. 2
(Units: 58)
Total Marks: 100 Pass Marks: 50
Q. 1 (a) Write a program that prints the squares of all the numbers from 1 to 20.
(b) What is the difference in execution sequence of the body of a do-while loop and a while
loop? Explain with examples.
Q. 2 (a) What is the difference between break and continue statements? Explain with the help of
suitable example.
(b) For what purpose functions are used? Explain the structure of functions with the help of an
example.
Q. 3 (a) What is a return statement? What are its limitations?
(b) What are pre-processor directives? Explain the concept of header files.
(c) What are the main differences between functions and macros? Explain.
Q. 4 (a) How single dimensional, two-dimensional, and three-dimensional arrays are initialized? How
these arrays can be passed as arguments? Explain by using an example.
(b) How sorting operation can be performed on arrays? Explain the sorting operation by using
bubble sort.
Q. 5 (a) What is a pointer? Why are pointers used? What is an indirection operator?
(b) How pointer variables are defined? How values are supplied to pointer variables?
(c) Write a program using pointer notation to access individual elements of an array and print the
sum and average of the elements of the array.
docsity.com

Partial preview of the text

Download C Programming Assignment 2: Squares, Loops, Functions, and Arrays and more Exercises Computer Programming in PDF only on Docsity!

ASSIGNMENT No. 2

(Units: 5–8) Total Marks: 100 Pass Marks: 50

Q. 1 (a) Write a program that prints the squares of all the numbers from 1 to 20. (b) What is the difference in execution sequence of the body of a do-while loop and a while loop? Explain with examples.

Q. 2 (a) What is the difference between break and continue statements? Explain with the help of suitable example. (b) For what purpose functions are used? Explain the structure of functions with the help of an example.

Q. 3 (a) What is a return statement? What are its limitations? (b) What are pre-processor directives? Explain the concept of header files. (c) What are the main differences between functions and macros? Explain.

Q. 4 (a) How single dimensional, two-dimensional, and three-dimensional arrays are initialized? How these arrays can be passed as arguments? Explain by using an example. (b) How sorting operation can be performed on arrays? Explain the sorting operation by using bubble sort.

Q. 5 (a) What is a pointer? Why are pointers used? What is an indirection operator? (b) How pointer variables are defined? How values are supplied to pointer variables? (c) Write a program using pointer notation to access individual elements of an array and print the sum and average of the elements of the array.

docsity.com