Chapter - 9: Arrays

Write a program which performs the following tasks:


I
Sections
4
Exercises

- initialize an integer array of 10 elements in main( )
- pass the entire array to a function modify( )
- in modify( ) multiply each element of array by 3
- return the control to main( ) and print the new array elements in main( )


#include<stdio.h>
#include<conio.h>
void modify(int *elem)
{
	int i;
	for (i = 0; i<10; i++, elem++)
		*elem *= 3;
}
int main()
{
	int arr[] = { 10,20,30,40,50,60,70,80,90,100 }, i;
	modify(arr);
	for (i = 0; i<10; i++)
		printf("%d ", arr[i]);
	_getch();
	return 0;
}

© 2021 Garbage Valuegarbage value logo