Skip to content

UMK-Data-Science/week-3-array-operations

Repository files navigation

Tutorial 3 - Additional Tutorial for Array

This is an additional tutorial composed with array for 1D, 2D and pointers. Please answer all questions and read carefully :octocat:

Instructions

This tutorial consists with 10 questions:

  • Exercise 1
  • Exercise 2
  • Exercise 3
  • Exercise 4
  • Exercise 5
  • Exercise 6
  • Exercise 7
  • Exercise 8
  • Exercise 9
  • Exercise 10

Try to complete this tutorial by commit your changes and read the question carefully 🚀

Exercise 1 - Onedimensional Array

Using printf, display a string "I Love Programming!"

Exercise 2 - Onedimensional Array

Using gets and printf, display a string "I am a Bachelor Degree Student from Universiti Malaysia Kelantan"

Exercise 3 - Onedimensional Array

Using fgets and puts, display a string "Practice Makes Perfect!"

Exercise 4 - Onedimensional Array

Write a program to find the summation of array elements as follow (note: use loop in this program):

num[] = {10.0, 22.5, 15.5, 32.5, 10.9, 67.9, 12.5, 11.9, 25.5, 100.0};

Exercise 5 - Onedimensional Array

Write a program to display a string "Practice Makes Perfect!". Next, print 8-th element from the string as follow:

8-th element from the string is: _____

Exercise 6 - Multidimensional Array

Write a program to display a multidimensional (2D) array as follow (note: use nested loop in this program as to read rows and columns):

Element at x[0][0]: 0
Element at x[0][1]: 2
Element at x[1][0]: 4
Element at x[1][1]: 6
Element at x[2][0]: 8
Element at x[2][1]: 10

Exercise 7 - Passing Array to Function

Based from Exercise 4, write a program to calculate summation of array element by passing an array to a function (note: create a function name summationArray)

Exercise 8 - Passing Array to Function

Based from Exercise 6, write a program to display a multidimensional (2D) array by passing an array to a function (note: create a function name displayElement)

Exercise 9 - Pointers

Write a program to display the address each of element below: (note: use loop in this program)

myArray[] = {1,2,3,4,5};

Exercise 10 - Pointers

Create pointer name ptr and assigned the address of this pointer to variable name myVariable where the value store in myVariable is 100. Next, print the address and value of ptr as follow:

Address for ptr is: ____
Value for ptr is: ____

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages