0% found this document useful (0 votes)
16 views2 pages

DSA Lab 01 1

The document outlines a DSA lab assignment consisting of seven programming tasks in C/C++. Each task requires the implementation of specific algorithms and functions, including finding the GCD using the Euclidean algorithm, generating the Fibonacci series, calculating the area and perimeter of a rectangle, calculating the volume and surface area of a cylinder, converting total days into years, months, and days, string manipulation, and splitting a sentence into words. All tasks emphasize user input validation, error checking, and the use of appropriate variable types.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

DSA Lab 01 1

The document outlines a DSA lab assignment consisting of seven programming tasks in C/C++. Each task requires the implementation of specific algorithms and functions, including finding the GCD using the Euclidean algorithm, generating the Fibonacci series, calculating the area and perimeter of a rectangle, calculating the volume and surface area of a cylinder, converting total days into years, months, and days, string manipulation, and splitting a sentence into words. All tasks emphasize user input validation, error checking, and the use of appropriate variable types.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DSA Lab

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:

1. Use a function (generateFibonacci) to generate the Fibonacci series.


2. The program should handle positive integers for the number of terms.
3. Validate user input to ensure that a positive integer is entered.
4. Use appropriate variable types and error checking.

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:

1. Use functions (calculateArea and calculatePerimeter) to perform


calculations.
2. The program should handle positive values for the length and width.
3. Validate user input to ensure that positive values are entered.
4. Use appropriate variable types and error checking.

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:

1. Use functions (calculateVolume and calculateSurfaceArea) to perform


calculations.
2. The program should handle positive values for the radius and height.
3. Validate user input to ensure that positive values are entered.
4. Use appropriate variable types and error checking.

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.

You might also like