PROBLEM 1
//Create an array of 10 numbers
//output the contents of the 3rd and 8th locations
//output all the contents of the array
#include<stdio.h>
#include<conio.h>
int main()
int num[10]={0}; //initialize te contents of the array to 0
int ctr=0;
//creation of the array
for(ctr=0; ctr<10; ctr++)
printf("Enter element of num[%d]:", ctr);
scanf("%d", &num[ctr]); //kindly observe how array is done in scanf
//print the contents of location 3 and 4
printf("*********Printing the contents of location 3 and 8\n");
printf("num[3]=%d",num[3]); //printing the content of location 3
printf("\nnum[8]=%d", num[8]); //printing the content of location 8
//printing the entire contents of the array; loop is to be used to access each element
printf("\n*********Printing all the contents of the array\n");
for(ctr=0; ctr<10; ctr++)
printf("num[%d]=%d", ctr, num[ctr]);
printf("\n");
return 0;
PROBLEM 2
//Create an array of 10 numbers
//output the highest number in the array
#include<stdio.h>
#include<conio.h>
int main()
int num[10]={0}; //initialize te contents of the array to 0
int ctr=0, high;
//creation of the array
for(ctr=0; ctr<10; ctr++)
printf("Enter element of num[%d]:", ctr);
scanf("%d", &num[ctr]); //kindly observe how array is done in scanf
//Searching the highest number in the array
high=num[0]; //Assume the the first element is the highest
for(ctr=0; ctr<10; ctr++)
{
if(num[ctr+1]>high) //start comparing element ctr+1m don't compare to your self
high=num[ctr+1];
printf("\n*********Printing highest number in the array\n");
printf("Highest is %d", high);
return 0;
PROBLEM 3
//Create an array of 10 numbers
//Print the contents of the original array
//Swap the contents of location 3 and location 8
//Print the new contents of the array
#include<stdio.h>
#include<conio.h>
int main()
int num[10]={0}; //initialize te contents of the array to 0
int ctr=0, temp;
//creation of the array
for(ctr=0; ctr<10; ctr++)
printf("Enter element of num[%d]:", ctr);
scanf("%d", &num[ctr]); //kindly observe how array is done in scanf
printf("*********Printing contents of the original array");
for(ctr=0; ctr<10; ctr++)
printf("\nnum[%d]=%d", ctr, num[ctr]);
//This is how to swap the contents of location 3 and location 8
temp=num[3]; //assign the content of location 3 to temp
num[3]=num[8]; //assign the content of location to location 3
num[8]=temp; //assign the content of temp to location to location 8
printf("*********Printing contents of the new array\n");
for(ctr=0; ctr<10; ctr++)
printf("\nnum[%d]=%d", ctr, num[ctr]);
return 0;
PROBLEM 4
//Create an array of 10 numbers
//Print the sum of the contents of the array
#include<stdio.h>
#include<conio.h>
int main()
int num[10]={0}; //initialize te contents of the array to 0
int ctr=0, sum=0;
//creation of the array
for(ctr=0; ctr<10; ctr++)
printf("Enter element of num[%d]:", ctr);
scanf("%d", &num[ctr]); //kindly observe how array is done in scanf
printf("*********Printing contents of the original array");
for(ctr=0; ctr<10; ctr++)
printf("\nnum[%d]=%d", ctr, num[ctr]);
//This is how to get the sum of the contents of the array
for(ctr=0; ctr<10; ctr++)
sum+=num[ctr];
printf("\n********The sum=%d", sum);
return 0;
}
PROBLEM 5
//Create a multidimensional array
//Print the contents of the multidimensional array
//Create an nxm Matrix, n=row, m=column
#include<stdio.h>
#include<conio.h>
int main()
int Matrix[100][100]; //maximize the row a and columns of Matrix to 100
int row, col, maxrow, maxcol;
printf("How many rows and columns is your Matrix?:");
scanf("%d %d", &maxrow, &maxcol);
//creation of the Matrix
for(row=0; row<maxrow; row++)
for(col=0; col<maxcol; col++)
printf("Enter element of Matrix[%d %d]:", row, col);
scanf("%d", &Matrix[row][col]);
} //kindly observe how multidimensional array is done in scanf
printf("*********Printing contents of the Matrix\n");
for(row=0; row<maxrow; row++)
for(col=0; col<maxcol; col++)
{
printf("%d ", Matrix[row][col]);
printf("\n"); // to print the elements of next row
return 0;