Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need some help creating a few functions out of main using C++, my main functio

ID: 3903322 • Letter: I

Question

I need some help creating a few functions out of main using C++, my main function is prewritten I am just lost on trying to create the functions. I am creating a box or square cipher (5 x 5), where I will be encrypting 2 characters at once. To begin I am given these equations and need to create three functions based on these equations.

{ row=index/width

column= index (mod) width

index = row * width + column}

Fn1cell to index ( takes in 2 values x and y of type size_t)

and returns size_t

fn2 index to cell x (takes in index of type size_t)

and returns size_t

fn3 index to cell y(takes in index of type size_t)

and return size_t

If anyone can provide any help it would be greatly appreciated.

Explanation / Answer

//function fn1 can be written as

//Assumption width is already defined

size_t fn1(size_t x,size_t y){

index = x * width + y;

return index;

}

//Definition of fn2

size_t fn2(size_t index){

//compute the row from index

x = index/width;

return x;

}

//Definition for fn3

size_t fn3(size_t y){

//Compute the column from index

y = index%width;

return y;

}