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

Functions

The document contains exercises to write functions and procedures to perform various mathematical and string operations like calculating prices with VAT, determining if a number is even or odd, finding the length of a string, counting the occurrences of a character in a string, calculating absolute values, generating multiplication tables, finding the greatest common divisor of two numbers, calculating sums and products, reading lists of integers, displaying even numbers between two values, determining if a number is prime, calculating factorials recursively, finding sums recursively, exponentiation recursively, and recursively displaying integers and finding the greatest common divisor.

Uploaded by

rym.nassih
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)
9 views2 pages

Functions

The document contains exercises to write functions and procedures to perform various mathematical and string operations like calculating prices with VAT, determining if a number is even or odd, finding the length of a string, counting the occurrences of a character in a string, calculating absolute values, generating multiplication tables, finding the greatest common divisor of two numbers, calculating sums and products, reading lists of integers, displaying even numbers between two values, determining if a number is prime, calculating factorials recursively, finding sums recursively, exponentiation recursively, and recursively displaying integers and finding the greatest common divisor.

Uploaded by

rym.nassih
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
You are on page 1/ 2

Functions

Exercise 52

Write a function to calculate the price including VAT. This function will receive a Real parameter
named "prixHT" and a second Real parameter named "tva".

Exercise 53

Write a procedure to display whether an integer passed as a parameter is even or odd.

Exercise 54

Write a function to return the number of characters in a string passed as a parameter.

Exercise 55

Write a function to find out how many times a character occurs in a string. The character to be
searched for and the string will be passed as parameters .

Exercise 56

Write a function or procedure that calculates the absolute value of a number.

Exercise 57

Write a procedure to display the multiplication table of a positive integer x.

Exercise 58

Write a function that calculates the PGCD of two strictly positive integers.

Exercise 59

Write a procedure that reads two numbers, calculates their sum and product and displays whether
they are positive or negative.

Exercise 60

Write a procedure that reads a list of integers (N numbers) whose last value = -1

and displays the number of even integers and their percentage of the given number of integers.
Exercise 61

Write a procedure to enter two values M and N and display all even values between M and N if M<N.

Exercise 62

Write a procedure that displays whether a number is prime or not .

Recursive functions
Exercise 63

Write a recursive function to calculate the factorial of an integer entered by the user.

Exercise 64

Write a recursive function to calculate the sum 1+2+3+...+ N. where N is entered by the user.

Exercise 65

Write a recursive function that, given a real number x and a positive integer value n, calculates x to
the nth power.

Exercise 66

Write a recursive function to display integers from 0 to 10 using a single parameter.

Exercise 67

Write a recursive function to display the integers from A to B . Where A and B are parameters of this
function.

Exercise 68

Write a recursive function to calculate the PGCD of two integers passed as parameters,( using Euclid's
algorithm).

You might also like