0% found this document useful (0 votes)
3 views2 pages

30 Essential Programming Functions

The document contains a list of programming tasks divided into three sections: basic functions, functions with arrays, and functions with loops. Each section includes ten specific questions that require writing functions to perform various operations, such as calculating sums, checking conditions, and manipulating arrays. The tasks are designed to test and enhance programming skills in function creation and array handling.

Uploaded by

mominsarfraz567
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)
3 views2 pages

30 Essential Programming Functions

The document contains a list of programming tasks divided into three sections: basic functions, functions with arrays, and functions with loops. Each section includes ten specific questions that require writing functions to perform various operations, such as calculating sums, checking conditions, and manipulating arrays. The tasks are designed to test and enhance programming skills in function creation and array handling.

Uploaded by

mominsarfraz567
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

FUNCTION (10 Questions)

1.​ Write a function that takes a number and returns its square.​

2.​ Write a function that takes two numbers and returns their sum.​

3.​ Write a function that checks if a number is even or odd.​

4.​ Write a function that returns the larger of two numbers.​

5.​ Write a function that prints “Hello World”.​

6.​ Write a function that takes a name and returns “Hello, ”.​

7.​ Write a function that returns the area of a rectangle (length × width).​

8.​ Write a function that converts Celsius to Fahrenheit.​

9.​ Write a function that checks if a number is positive, negative, or zero.​

10.​Write a function that takes age and returns “Adult” or “Minor”.

FUNCTION + ARRAY (10 Questions)


11.​Write a function that takes an array and returns its first element.​

12.​Write a function that takes an array and returns its last element.​

13.​Write a function that returns the length of an array.​

14.​Write a function that finds the largest number in an array.​

15.​Write a function that finds the smallest number in an array.​

16.​Write a function that returns the sum of all numbers in an array.​

17.​Write a function that checks if a value exists in an array.​

18.​Write a function that returns a new array with only even numbers.​

19.​Write a function that returns a new array with numbers doubled.​

20.​Write a function that reverses an array without using built-in reverse().


FUNCTION + LOOP (10 Questions)
21.​Write a function that prints numbers from 1 to 10 using a loop.​

22.​Write a function that prints even numbers from 1 to 50.​

23.​Write a function that returns the factorial of a number.​

24.​Write a function that counts how many times a letter appears in a string.​

25.​Write a function that prints the multiplication table of a number.​

26.​Write a function that sums all numbers from 1 to n.​

27.​Write a function that counts the number of vowels in a string.​

28.​Write a function that checks if a number is prime.​

29.​Write a function that prints all elements of an array using a loop.​

30.​Write a function that finds the total of only odd numbers in an array.

You might also like