DSA Lab 01 1
DSA Lab 01 1
Assignment-1
Q1: Write a C/C++ program to find the Greatest Common Divisor (GCD) of two positive integers
using the Euclidean algorithm. The program should take two integers as input from the user and
output the GCD.
Requirements:
1. Use a function to implement the Euclidean algorithm for finding the GCD.
2. The program should handle only positive integers.
3. Validate user input to ensure that positive integers are entered.
4. Use appropriate variable types and error checking.
Q2: Write a C/C++ program to generate the Fibonacci series up to a specified term. Implement
a function named generateFibonacci that takes an integer n as a parameter and prints the
Fibonacci series up to the 𝑛!" term. The program should take user input for the number of
terms and output the corresponding Fibonacci series.
Requirements:
Q3: Write a C/C++ program to calculate the area and perimeter of a rectangle. Implement
functions calculateArea and calculatePerimeter that take the length and width of the
rectangle as parameters and return the area and perimeter, respectively. The program should
take user input for the length and width of the rectangle and output the calculated area and
perimeter.
Requirements:
Q4: Write a C/C++ program to calculate the volume and surface area of a cylinder. Implement
functions calculateVolume and calculateSurfaceArea that take the radius and height of
the cylinder as parameters and return the volume and surface area, respectively. The program
should take user input for the radius and height of the cylinder and output the calculated volume
and surface area.
Requirements:
Q5: Write a C/C++ program that takes an input for the total number of days and calculates the
corresponding day, month, and year. It also checks whether the calculated year is a leap year or
not.
Q6: Write a program in C/C++ takes a string as input and prints its length, reverses the string,
and checks whether it is a palindrome or not.
Q7: Write a program in C/C++ for the split function to split a sentence (as a char array) then
split and store its words into another array of character arrays.