0% found this document useful (0 votes)
42 views16 pages

100 Programming Exercises for Beginners

The document outlines a comprehensive list of programming exercises categorized into various topics such as Basic Input/Output, Control Structures, Loops, Arrays, Strings, Functions, Pointers, Recursion, Sorting and Searching, Bitwise Operations, and Patterns. Each category contains multiple tasks aimed at developing programming skills through practical implementation. The exercises range from simple tasks like printing messages to more complex problems involving algorithms and data structures.
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)
42 views16 pages

100 Programming Exercises for Beginners

The document outlines a comprehensive list of programming exercises categorized into various topics such as Basic Input/Output, Control Structures, Loops, Arrays, Strings, Functions, Pointers, Recursion, Sorting and Searching, Bitwise Operations, and Patterns. Each category contains multiple tasks aimed at developing programming skills through practical implementation. The exercises range from simple tasks like printing messages to more complex problems involving algorithms and data structures.
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

Programs to work:

Basic Input/Output

1. Write a program to print "Hello, World!" to the console.

2. Write a program to read an integer and print it.

3. Write a program to read two integers and print their sum.

4. Write a program to read a float and print it with two decimal points.

5. Write a program to read a character and print its ASCII value.

6. Write a program to read a string and print it in reverse order.

7. Write a program to convert a given string to uppercase.

8. Write a program to count the number of words in a sentence.

9. Write a program to print the multiplication table of a given number.

10. Write a program to calculate the area and circumference of a circle given its radius.

Control Structures

11. Write a program to check if a number is even or odd.

12. Write a program to check if a number is positive, negative, or zero.

13. Write a program to find the largest of three numbers.

14. Write a program to find the smallest of three numbers.

15. Write a program to check if a character is a vowel or a consonant.

16. Write a program to determine whether a given year is a leap year.

17. Write a program to find the roots of a quadratic equation.

18. Write a program to calculate the grade based on marks.

19. Write a program to simulate a simple calculator using switch-case.

20. Write a program to check if a number is prime.

Loops
21. Write a program to print the first 10 natural numbers.

22. Write a program to print the sum of the first 10 natural numbers.

23. Write a program to print the factorial of a given number.

24. Write a program to find the sum of digits of a given number.

25. Write a program to reverse a given number.

26. Write a program to print all prime numbers up to a given number.

27. Write a program to print the Fibonacci series up to a given number.

28. Write a program to calculate the power of a number using a loop.

29. Write a program to print the sum of even and odd numbers separately from 1 to N.

30. Write a program to find the GCD of two numbers using loops.

Arrays

31. Write a program to find the largest element in an array.

32. Write a program to find the smallest element in an array.

33. Write a program to find the sum of all elements in an array.

34. Write a program to reverse an array.

35. Write a program to count the number of even and odd elements in an array.

36. Write a program to search for an element in an array.

37. Write a program to sort an array in ascending order.

38. Write a program to merge two sorted arrays.

39. Write a program to find the second largest element in an array.

40. Write a program to rotate an array to the right by a given number of steps.

Strings

41. Write a program to find the length of a string.

42. Write a program to reverse a string.

43. Write a program to check if a string is a palindrome.

44. Write a program to concatenate two strings.


45. Write a program to count the number of vowels in a string.

46. Write a program to remove all vowels from a string.

47. Write a program to find the frequency of each character in a string.

48. Write a program to check if two strings are anagrams.

49. Write a program to find the first non-repeating character in a string.

50. Write a program to replace all spaces in a string with a hyphen.

Functions

51. Write a program to create a function to find the maximum of two numbers.

52. Write a program to create a function to find the factorial of a number.

53. Write a program to create a function to check if a number is prime.

54. Write a program to create a function to calculate the sum of digits of a number.

55. Write a program to create a function to swap two numbers.

56. Write a program to create a function that returns the nth Fibonacci number.

57. Write a program to create a function that checks if a string is a palindrome.

58. Write a program to create a function to calculate the GCD of two numbers.

59. Write a program to create a function to sort an array.

60. Write a program to create a function to convert a binary number to decimal.

Pointers (If Applicable)

61. Write a program to demonstrate pointer arithmetic.

62. Write a program to swap two numbers using pointers.

63. Write a program to find the sum of elements in an array using pointers.

64. Write a program to reverse a string using pointers.

65. Write a program to find the length of a string using pointers.

Recursion
66. Write a program to find the factorial of a number using recursion.

67. Write a program to find the nth Fibonacci number using recursion.

68. Write a program to find the greatest common divisor (GCD) of two numbers using recursion.

69. Write a program to reverse a string using recursion.

70. Write a program to calculate the power of a number using recursion.

Sorting and Searching

71. Write a program to implement bubble sort.

72. Write a program to implement selection sort.

73. Write a program to implement insertion sort.

74. Write a program to implement merge sort.

75. Write a program to implement quicksort.

76. Write a program to implement linear search.

77. Write a program to implement binary search.

78. Write a program to implement binary search on a sorted array.

79. Write a program to implement counting sort.

80. Write a program to find the frequency of elements in an array.

l Problems

81. Write a program to find the sum of all prime numbers less than a given number.

82. Write a program to find the sum of the squares of the first n natural numbers.

83. Write a program to generate Fibonacci numbers up to a given limit.

84. Write a program to find the sum of all even numbers up to a given number.

85. Write a program to find the sum of all odd numbers up to a given number.

86. Write a program to calculate the area of a triangle given its three sides.

87. Write a program to check if a number is an Armstrong number.

88. Write a program to find the least common multiple (LCM) of two numbers.

89. Write a program to solve a quadratic equation.


90. Write a program to find the sum of the first n terms of an arithmetic progression.

Bitwise Operations

91. Write a program to count the number of set bits in an integer.

92. Write a program to swap two numbers using bitwise XOR.

93. Write a program to check if a number is even or odd using bitwise operators.

94. Write a program to find the maximum of two numbers using bitwise operators.

95. Write a program to find the minimum of two numbers using bitwise operators.

96. Write a program to multiply a number by 2 using bitwise shift.

97. Write a program to divide a number by 2 using bitwise shift.

98. Write a program to find the bitwise AND, OR, and XOR of two numbers.

99. Write a program to toggle the k-th bit of a number.

[Link] a program to check if a number is a power of two using bitwise operations.


Basic Star Patterns

1. Write a program to print the following pattern:

*
**
***
****

2. Write a program to print the following pattern:

****
***
**
*

3. Write a program to print the following pattern:

*
**
***
****
*****

4. Write a program to print the following pattern:

*****
****
***
**
*

5. Write a program to print the following pattern:


*
**
***
****

6. Write a program to print the following pattern:

****
***
**
*

7. Write a program to print the following pattern:

*
**
***
**
*

8. Write a program to print the following pattern:

****
***
**
*

9. Write a program to print the following pattern:

*
**
***
****
***
**
*
10. Write a program to print the following pattern:

*****
* *
* *
* *
*****

Number Patterns

11. Write a program to print the following pattern:

1
12
123
1234

12. Write a program to print the following pattern:

4321
321
21
1

13. Write a program to print the following pattern:

1
22
333
4444

14. Write a program to print the following pattern:

1
23
456
7 8 9 10

15. Write a program to print the following pattern:


1
121
12321
1234321

16. Write a program to print the following pattern:

1
23
456
7 8 9 10

17. Write a program to print the following pattern:

1
22
333
4444

18. Write a program to print the following pattern:

1234
123
12
1

19. Write a program to print the following pattern:

1
23
456
7 8 9 10

20. Write a program to print the following pattern:

1234
5678
9 10 11 12

Alphabet Patterns

21. Write a program to print the following pattern:


A
BB
CCC
DDDD

22. Write a program to print the following pattern:

A
AB
ABC
ABCD

23. Write a program to print the following pattern:

A
BC
DEF
GHIJ

24. Write a program to print the following pattern:

A
BB
CCC
DDDD

25. Write a program to print the following pattern:

ABCD
ABC
AB
A

26. Write a program to print the following pattern:


A
BB
CCC
DDDD

27. Write a program to print the following pattern:

A
BB
CCC
BB
A

28. Write a program to print the following pattern:

A
BC
DEF
GHIJ

29. Write a program to print the following pattern:

ABCD
ABC
AB
A

30. Write a program to print the following pattern:

D
CD
BCD
ABCD

Pyramid Patterns

31. Write a program to print the following pattern:


*
**
***
****

32. Write a program to print the following pattern:

1
12
123
1234

33. Write a program to print the following pattern:

A
AB
ABC
ABCD

34. Write a program to print the following pattern:

*
**
***
****
***
**
*

35. Write a program to print the following pattern:

1
22
333
4444

36. Write a program to print the following pattern:


A
BB
CCC
DDDD

37. Write a program to print the following pattern:

1
23
456
7 8 9 10

38. Write a program to print the following pattern:

A
BC
DEF
GHIJ

39. Write a program to print the following pattern:

1
12
123
1234
123
12
1

40. Write a program to print the following pattern:

*
**
***
****
***
**
*
Diamond Patterns

41. Write a program to print the following pattern:

*
**
***
****
***
**
*

42. Write a program to print the following pattern:

1
12
123
1234
123
12
1

43. Write a program to print the following pattern:

A
AB
ABC
ABCD
ABC
AB
A

44. Write a program to print the following pattern:

*
**
***
****
****
***
**
*

45. Write a program to print the following pattern:

1
23
456
7 8 9 10
123
45
6

46. Write a program to print the following pattern:

A
BC
DEF
GHIJ
ABC
DE
F

47. Write a program to print the following pattern:

1
12
123
1234
1234
123
12
1

48. Write a program to print the following hourglass pattern:

* * * * *
* * * *
* * *
* *
*
* *
* * *
* * * *
* * * * *
49. Write a program to print the following zig-zag pattern:
1 7
2 6
3 5
4
5 3
6 2
7 1

50. Write a program to print the following spiral pattern:


12345
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

You might also like