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

Using C: 1.) Write a program called hw6.c that is just main.c with the skeleton

ID: 3914460 • Letter: U

Question

Using C:

1.) Write a program called hw6.c that is just main.c with the skeleton we use on all of our projects. The following items will all be added to this program and called top to bottom from main/hw6.c. 2.) In main, create a function called excercise1 that takes no arguments and returns a Boolean "bool". You will need to #include in main to do so. This will prepare you to write function declarations and functions that take an array as an argument. a. Inside exercise10 I want you to declare a single dimensional FLA array of 10 integers. Initialize the array to all zeros Write a function called load_array1, which takes the entire FLA array (pp475) as an argument and returns a Boolean value. Function load_array will take the array and using a for loop will populate the elements with the counter squared. So for each iteration store the iterator by tself in the array position of the iteration. When the function is done, return a true' to the caller main or false if it fails. In main print an error message if its false nothing if its true. In main, call excercise10 which will then will call the load_array function, pass its array that you initialized to zeros. If load_array returns true, use another for loop in exercise:1 to print the array elements to screen and the return true to the caller (main.c aka hw6.c). 3.) In main, create a function called excercise2(0 that takes no arguments and returns a Boolean true on success.

Explanation / Answer

#include<stdio.h>

#include<stdbool.h>

bool load_array1(int *arr){

int i;

for(i=0;i<10;i++)

arr[i]=i*i;

if(i==10)return true;

else return false;

}

bool exercise1(){

int FLA[10],i;

for(i=0;i<10;i++)FLA[i]=0;

load_array1(FLA);

for(i=0;i<10;i++)

printf("%d ",FLA[i]);

printf(" ");

if(i==10)return true;

else return false;

}

bool reverse_array(char *arr){

int i=0,j=9;

char temp;

while(i<j){

temp=arr[i];

arr[i]=arr[j];

arr[j]=temp;

i++;

j--;

}

if(i>=j)return true;

else return false;

}

bool exercise2(){

char VLA[10];

int i;

bool result;

printf("enter 10 chacter ");

for(i=0;i<10;i++)

scanf("%c",&VLA[i]);

result=reverse_array(VLA);

if(result){

for(i=0;i<10;i++)

printf("%c",VLA[i]);

printf(" ");

return true;

}

else return false;

}

bool change_item(float *a){

int value;

printf("Enter new value : ");

scanf("%d",&value);

*a=value;

return true;

}

bool exercise3(){

float VLA[10];

int i;

printf("enter 10 float ");

for(i=0;i<10;i++)

scanf("%f",&VLA[i]);

int index;

printf("choose a number 1 to 10 : ");

scanf("%d",&index);

if(change_item(VLA+index-1)){

printf("changed array ");

for(i=0;i<10;i++)

printf("%f ",VLA[i]);

return true;}

else return false;

}

int main(){

bool result;

printf("inside example1 ");

exercise1();

printf(" inside example2 ");

exercise2();

printf(" inside example3 ");

exercise3();

return 0;

}

for any query please comment.

please upvote if find helpful.

Thank you!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote