Skip to content

Exercise

What to do?

  1. Create a function named printGreeting that takes no parameters. Inside the function, print a predefined greeting message, such as "Welcome to Our Website! Enjoy your visit!". Implement the function, then call and print it.
  2. Write a function named generateRandomNumber that generates and returns a random number between 1 and 100 (inclusive) without any input. Develop the generateRandomNumber function, then call and print the generated random numbers.
  3. Create a function named calculateArea that takes two parameters: length and width of a rectangle. Inside the function, calculate the area using the formula: Area = Length × Width. Then develop the calculateArea function and demonstrate its usage in the main function by providing values for length = 7 and width = 5, then print the calculated area.
  4. Write a function named calculateFactorial that takes an integer parameter n. Inside the function, calculate and return the factorial of n. Implement the calculateFactorial function and demonstrate its usage in the main function by calculating the factorial of 6, then print the result.