Code Comprehension Questions
Code Comprehension Questions
1. Write a function in C and Python to calculate the Fibonacci sequence up to the 7th
term.
2. Write a program in both C and Python to perform bitwise manipulation, such as
checking if a number is even or odd, without using conditional statements.
3. Implement a function in C that uses pointers to reverse an array in place. Then, write
an equivalent function in Python.
4. Implement the Armstrong number check using both a recursive and an iterative
approach in both C and Python.
5. Write a program in C and Python to compare two strings without using string library
functions.
6. Write a program in C and Python to find maximum and minimum of some values.
7. Write a program in C and Python to find the sum of all elements in a matrix (2D
array). Implement row-wise traversal using pointers in C, and use nested loops in
Python.
8. Implement a program in C to count the number of vowels in a given string using
pointers. Write an equivalent function in Python without using the count method.
9. Check whether a given number is super prime? By using C and Python ( For example
7331 is super prime because 7331 is prime, 733 is prime, 73 is prime,7 is prime, Such
numbers are called super prime)
10. Implement the Sieve of Eratosthenes algorithm in both C and Python to generate prime
numbers up to a large value.
11. Find the LCM of 2 numbers using C & Python
12. Write a program in C and Python to find all perfect numbers up to a given limit
13. Write a program in C and Python to find all Harshad numbers(Number divisible by sum
of its digits) up to a given limit
14. Write a program to implement a function in both C and Python to transpose a 2x3 matrix
(convert rows to columns). The matrix should be taken as input from the user.
15. Implement a simple calculator program in C using function pointers. The calculator
should support addition, subtraction, multiplication, and division. Write the equivalent
program in Python using a dictionary of functions.
16. Write a program in both C and Python to find the maximum element in an array using
pointers (C) or direct list traversal (Python). The array and its size should be passed as
arguments to the function.
17. Write a program to implement a function in both C and Python to find the length of a
given string using pointers (in C) or slicing (in Python). Do not use any built-in functions like
strlen() or len().
18. Write a program in both C and Python that calculates the sum of all elements in an array.
In C, use pointers to traverse the array, and in Python, use a loop.
19. Write a program in both C and Python to implement a recursive function that calculates
the factorial of a number. Compare the memory usage and execution speed of both programs
when calculating large factorials (e.g., factorial of 100). Why might C handle this task
differently from Python, and how does memory management in each language affect the
result?
20. Write a program in both C and Python to add two floating-point numbers and compare the
results for precision when the numbers are very close in value (e.g., 0.123456789 +
0.000000001). Discuss the precision differences in floating-point arithmetic between the two
languages, focusing on how they handle numerical data types and the implications for
scientific computing.
21. Write a program in both C and Python to perform bitwise manipulation to check if a
number is a power of 2. Discuss how bitwise operations differ in terms of efficiency between
the two languages, especially in cases where low-level memory control is crucial.
22. Write a C and Python function that takes two sorted lists of test scores and merges them
into a single sorted list without using built-in sort function.
23. Write a Python function that finds the mode (most frequent element) in a list of integers.
If there’s a tie, return any one of the most frequent elements.
24. Write a program to rotate a square matrix by 90 degrees clockwise.
25. Write a program to find the maximum product of any two elements in an array.
26. Write a program in both C and Python to find all superperfect numbers up to a given
limit.
27. Write a program in both C and Python to find all happy primes up to a given limit.
28. Write a program in both C and Python to calculate the determinant of a large matrix.
29. Write a program in both C and Python to calculate the GCD of two large numbers using
the Euclidean algorithm.
30.Write a program in both c and python to Implement a function that takes two strings as
input and checks if the second string is a substring of the first. If found, return the starting
position of the substring; otherwise, return -1.
31. Write a program in C and Python that finds the prime factors of a large number.
32. WAP in C and python to multiply two matrices.
33. WAP in python and C to multiply a number by 3 if the first, third, and the eight digit of a
12-digit number are equal.
34. Consider a class of students divided into ten teams, each with a team head. Ask the team
heads to choose from the four colors {RED, BLUE, GREEN, YELLOW} which identify their
teams. Identify the team chosen a unique color and display the team member names. If none
of the teams selected a unique color, display None. Implement the solution using C and
Python and compare the effectiveness of the implementations based on the language
characteristics.
35. Student names and the marks secured by the student in the PPS subject are recorded by
the subject handling staff after conducting a class test. The staff is keen to know the best,
average, and worst performers of his/her class. Help him/her to determine and display the
name and mark secured by the best, average, and worst performer of his/her class. Implement
the solution using C and Python and compare the effectiveness of the implementations based
on the language characteristics.
36. Write a program in both C and Python that performs division and includes error handling
for divide-by-zero error. Prompt the user for two numbers and print the result of their
division.
37. Write a Program to Rotate a matrix by 90 degrees in the clockwise direction in C and
python.
38. Design an application to simulate a traffic light system. Define an enumeration type for
the states of the traffic light (e.g., RED, YELLOW, GREEN) and write a C and python
function that prints the current state of the light based on the enumeration value.
39. Given a list of email addresses, count the number of unique email addresses and print
them. Implement the solution using C and python.
40. Write a program in both C and Python to identify all happy numbers up to a certain limit.