Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Programming examples

1. Hello, World!: Write a program that prints the message “Hello, World!”.
2. Sum of Two Numbers: Write a program that asks the user to enter two numbers, and then prints the sum of those two numbers.
3. Addition: Write a program that assigns three numbers to variables num1, num2 and num3, and then calculates their sum and stores it in a variable result. Finally, print the value of result.
4. Even or Odd: Write a program that asks the user to enter a number and then determines whether the number is even or odd.
5. String Concatenation: Write a program that concatenates two strings str1 and str2 and stores the result in a variable result.
6. Increment and Decrement: Write a program that increments and decrements the value of a variable num.
7. User Input: Write a program that asks the user to enter their name, stores it in a variable name, and then prints a greeting using the name.

Programming problems to practice functions:

1. Write a function that calculates the factorial of a given number N and returns the result.
2. Write a function that takes a string as input and determines whether it is a palindrome or not.
3. Write a function that takes two integers as input and calculates their greatest common divisor.
4. Write functions to calculate the area of different geometric shapes such as squares, rectangles, circles, and triangles.
5. Write a function that takes two strings as input and determines whether they are anagrams (contain the same characters in a different order) or not.
6. Write functions to convert temperatures between Fahrenheit and Celsius.

Programming problems to practice array:

1. Write a program that takes an array of integers as input and calculates the sum of all the elements in the array.
2. Write a program that takes an array of integers as input and calculates the average of all the elements in the array.
3. Write a program that takes an array of integers as input and determines the smallest element in the array.
4. Write a program that takes an array of integers as input and returns a new array with the elements in reverse order.
5. Write a program that takes an array of integers as input and sorts the elements in ascending or descending order.
6. Write a program that takes an array of integers and a target number as input and determines whether the target number is present in the array.
7. Write a program that takes an array of integers and a rotation count as input. Rotate the elements of the array to the right by the given rotation count.
8. Write a program that takes two arrays of integers as input and returns a new array containing the common elements between the two arrays.
9. Write a program that takes an array of integers and a value to remove as input. Remove all occurrences of the value from the array and return the modified array.

Word Problems:

1. Sandip wants to buy a new smartphone that costs Rs 5000. She has saved Rs 2500 so far. How much more money does Sandip need to save?
2. Dheeraj is planning a road trip. The total distance he wants to cover is 800 kilometers. If he has already driven 450 kilometers, how many more kilometers does he need to travel?
3. Ayushman wants to distribute 120 candies equally among his 5 friends. How many candies will each friend receive, and how many candies will be left with Ayushman?
4. PIn a store, a book costs Rs 250. If Kunal wants to buy 4 books, what will be the total cost?
5. A recipe requires 2 cups of milk, 1 cup of sugar, and 3 mangoes. If Adarsh wants to double the recipe, how much milk, sugar, and mangoes will he need?