Question
Write a C program that asks the user to enter a positive integer (the integer could be of any number of digits in the range
Write a C program that asks the user to enter a positive integer (the integer could be of any number of digits in the range of the integer type) and replace each digit by the sum of that digit plus 6 modulus 10. The program then should swap the first digit with the last digit before it displays the output. A sample input/output: Enter the number of digits of the number: 5 Enter the number: 92828 Output: 48485 1) Name your program replace2.c. 2) The user will enter the total number of digits before entering the number. 3) You can use format specifier "%1d" in scanf to read in a single digit into a variable (or an array element). For example, for input 101011, scanf("%1d", &num) will read in 1 to num. 4) As part of the solution, write and call the function replace() with the following prototype. The replace() function assumes that the digits are stored in the array a and computes the replaced digits and store them in the array b. c represents the size of the arrays. void replace(int *a, int *b, int n); The replace() 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. 5) As part of the solution, write and call the function swap() with the following prototype. void swap(int *p, int *q); When passed the addresses of two variables, the swap() function should exchange the values of the variables: swap(&i, &j); /* exchange values of i and j */
attached to be modified:
#include
int input[8]={0};int output[8]; int i;printf("please enter the 8 bit bar code");for(i=0;i<8;i++)
scanf("%1d", &input[i]);
edge(8, input, output);for(i=0;i<8;i++)
printf("%d", output[i]);
return 0;
} void edge(int n, int a[], int b[]){
int i;b[0]=0;for (i = 1;i else b[i]=1; }
Step 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