Skip to content

nirajan10/assignment-3-array_string_functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assignment 3: Array, Strings and Functions

Instructions

  1. Write code in the corresponding src/ file for each programming task.
  2. Upload a PDF containing all answers with output screenshot in the docs/ folder
    • You can create a doc and convert it to PDF online.
    • Name pdf as answer.pdf
    • Your first line of pdf should be Name: Firstname-Lastname. Eg: Name: Nirajan-Thakuri
  3. Do not change file names — tests depend on them.
  4. Commit and push your changes to GitHub.

Questions

Q1. Write a C program to find the maximum and minimum elements in an array.

Q2. Implement a C program to reverse the elements of an array.

Q3. Write a C program to sort an array of integers in ascending order using a sorting algorithm of your choice (e.g., bubble sort, selection sort, insertion sort).

Q4. Implement a C program to find the second largest element in an array.

Q5. Write a C program to merge two sorted arrays into a single sorted array.

Q6. Write a C program to find the length of a string without using the built-in string functions.

Q7. Implement a C program to reverse a string.

Q8. Write a C program to check if a given string is a palindrome.

Q9. Implement a C program to count the occurrence of a specific character in a string.

Q10. Write a C program to concatenate two strings without using the built-in string functions.

Q11. Write a function named calculateAverage that takes an array of integers as input and returns the average of the numbers.

Q12. Write a function named isPalindrome that takes a string as input and returns 1 if it is a palindrome (reads the same forwards and backwards), and 0 otherwise.

Q13. Write a function named findFactorial that takes an integer as input and returns its factorial.

Q14. Write a function named convertTemperature that takes a temperature value in Celsius and converts it to Fahrenheit. The function should return the converted temperature.

Q15. Write a function named countOccurrences that takes a string and a character as input and returns the number of times the character appears in the string.

Q16. Write a function named reverseArray that takes an array of integers as input and reverses the order of the elements in the array.

Q17. Write a function named calculatePower that takes two integers, base and exponent, as input and returns the result of raising the base to the exponent.

Q18. Write a function named findPrimeNumbers that takes an integer n as input and prints all prime numbers from 1 to n.

Q19. Write a function named calculateFactorialSeries that takes an integer n as input and prints the factorial series up to n.

Q20. Write a function named calculateGCD that takes two integers as input and returns their greatest common divisor (GCD).

Q21. Write a recursive function named calculateFactorial that takes an integer n as input and returns its factorial.

Q22. Write a recursive function named calculateFibonacci that takes an integer n as input and returns the nth Fibonacci number. The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the two preceding numbers.

Q23. Write a recursive function named calculateGCD that takes two integers a and b as input and returns their greatest common divisor (GCD).

Q24. Write a recursive function named calculatePower that takes two integers base and exponent as input and returns the result of raising the base to the exponent.

Q25. Write a recursive function named calculateSumOfDigits that takes an integer n as input and returns the sum of its digits.

Q26. Write a recursive function named reverseString that takes a string as input and returns the reversed string.

Q27. Write a recursive function named printTriangle that takes an integer n as input and prints a triangle of asterisks (*) with n rows.

Q28. Write a recursive function named calculateBinary that takes an integer n as input and returns its binary representation as a string.

Q29. Write a recursive function named isPalindrome that takes a string as input and returns 1 if it is a palindrome (reads the same forwards and backwards), and 0 otherwise.

Q30. Write a recursive function named countOccurrences that takes a string and a character as input and returns the number of times the character appears in the string.


Deadline: 23:59, Saturday, 15th Nov, 2025

About

Assignment 3 - Array, Strings and Functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published