21. Count the number of vowels in a string.

Required Input:

str = "hello world"

Expected Output:

Vowel Count = 3

Code In C

#include #include int main() { char str[] = "hello world"; int count = 0; // Logic to count vowels return 0; }

Output

Click Run Button to view compiled output

22. Convert a binary number to decimal.

Required Input:

binary = 1011

Expected Output:

Decimal = 11

Code In C

#include int main() { int binary = 1011; int decimal = 0, base = 1; // Logic to convert binary to decimal return 0; }

Output

Click Run Button to view compiled output

23. Calculate compound interest.

Required Input:

principal = 1000, rate = 5, time = 2

Expected Output:

Compound Interest = 1102.50

Code In C

#include int main() { float principal = 1000, rate = 5, time = 2; float compound_interest; // Logic to calculate compound interest return 0; }

Output

Click Run Button to view compiled output

24. Calculate the factorial of a number.

Required Input:

num = 5

Expected Output:

Factorial = 120

Code In C

#include int main() { int num = 5; int factorial = 1; // Logic to calculate factorial return 0; }

Output

Click Run Button to view compiled output

25. Check if a number is a perfect square.

Required Input:

num = 16

Expected Output:

Perfect Square

Code In C

#include int main() { int num = 16; // Logic to check perfect square return 0; }

Output

Click Run Button to view compiled output

26. Generate Fibonacci series up to n terms.

Required Input:

n = 5

Expected Output:

0 1 1 2 3 

Code In C

#include int main() { int n = 5; int a = 0, b = 1, next; // Logic to generate Fibonacci series return 0; }

Output

Click Run Button to view compiled output

27. Calculate the sum of digits of a number.

Required Input:

num = 1234

Expected Output:

Sum = 10

Code In C

#include int main() { int num = 1234; int sum = 0; // Logic to calculate sum of digits return 0; }

Output

Click Run Button to view compiled output

28. Swap two numbers without using a temporary variable.

Required Input:

a = 5, b = 3

Expected Output:

a = 3, b = 5

Code In C

#include int main() { int a = 5, b = 3; // Logic to swap values return 0; }

Output

Click Run Button to view compiled output

29. Find the maximum of three numbers.

Required Input:

a = 12, b = 25, c = 9

Expected Output:

Maximum = 25

Code In C

#include int main() { int a = 12, b = 25, c = 9; int max; // Logic to find maximum return 0; }

Output

Click Run Button to view compiled output

30. Calculate the sum of an array of integers.

Required Input:

arr = {2, 4, 6, 8, 10}

Expected Output:

Sum = 30

Code In C

#include int main() { int arr[] = {2, 4, 6, 8, 10}; int sum = 0; // Logic to calculate sum of array return 0; }

Output

Click Run Button to view compiled output

ad vertical

3 of 3