Question
Project 4 IT Program Design 1.(50 points) Note:This program will be graded based on whether the required functionality wereimplemented correctly(using pointer arithmetic) instead of whether
Project 4 IT Program Design
1.(50 points)
Note:This program will be graded based on whether the required functionality wereimplemented correctly(using pointer arithmetic) instead of whether it produces the correct output, for the functionality part (80% of the grade).
Modify three.c (Project 2, #2) the same_three function using pointer arithmetic. The function prototype should be the following. Name your program three2.c
.int same_three(int *a, int n);
The function should use pointer arithmetic, not subscripting to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function.
this is project three.c (project #2) that needs to be modified:
2.(50 points)
Write a program that rolls the first three elements of an array.
A sample input/output:
Enter the length of the array: 7
Enter the elements of the array: 5
3 4 9 8 7 2
Output:
The output array is:
4 5 3 9 8 7 2
1) Name your program roll3 .c
2)As part of the solution, write and call the function roll() with the following prototype.
The roll function should roll the first three elements of the array a1 by moving the third element of the array to the first in the output array a2
void roll (int *a1, int n, int *a2);
The roll() function should use pointer arithmetic not subscripting to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function
3)
In the main function, ask the user to enter the length of the array, declare the array with the length, read in the values for the array and call the
roll function. The main function should display the result.
int same three (int a[],int n) int main() f int n printf ("Enter the length of the array:"); scanf ( "%d", &n) ; //enter the length int i, a[n]; printf ("Enter the elements of the array:");//enter the elements for (i-0: iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started