Question
I need this in c programming assignment is given and also code is given you just have to code the lines where it says TODO
I need this in c programming
assignment is given and also code is given you just have to
code the lines where it says TODO here
please edit the code that i have given and please send me screenshot of the output as well
also tell me how to make compile and run
please only edit this below code shown. any other form will not work
please do both files as this is part of one single assignment
make file
squares.c file
#include #include
/* This program should print the sum of the elements * 1^2, 2^2, 3^2, ..., n^2 * where n is an integer provided by the user on the * command line. Hunt down the bugs and squash them! * Seek out the memory leaks and plug them up! */
/* Computes the sum of the first n elements in the array. */ int sum(int n, int* arr) { int i, sum; for(i = 0; i
/* Fills the given array with the values * 1^2, 2^2, 3^2, ..., (n-1)^2, n^2. */ void fillSquares(int n, int* arr) { int i; for(i = 1; i
/* Reads an integer n from arguments, * fills array with squares, and computes * the sum of the squares. Prints out the * sum before freeing all used memory. */ int main(int argc, char* argv[]) { int n, total; int* arr; printf("Enter a number: "); scanf("%d", &n); assert(n > 0); arr = (int*) malloc(n * sizeof *arr);
fillSquares(n, arr); total = sum(n, arr); printf("total: %d ", total); free(arr);
return 0; }
Part 2: argshift. [70 points] argshift is a program that takes a string as input, and shifts each letter in it forward by one letter (except z, which gets converted back to a). So, "abcz" should turn into "bcda" This includes capital letters, but does not include non-alphabetical characetrs, such as punctuation, spaces and digits. For this, you should implement the following functions: char shift char (char c) char* dup-shift (char* s) See the source code for more information about what each function should do. The memory space allocated for storing the return string should be dynamically allocated from the heap. You should allocate the least amount of space that can still hold the result. Your code should not change the string s. For this part you may use the standard library functions malloc, calloc, realloc, free and printf to manage dynamic memory allocation/deallocation and print the result. After you implement the function strdup-ptr) correctly, your code should work as in the sample runs listed below: $./argshift Enter a string: Ludicrous Speed, Go! Mvejdspvt Tqffe, Hp! You should fix all memory leaks (if any) in the code. It is highly recommended that you look at an ASCII chart when doing this assignment. One may be found by running man ascii # define more variables so it is easier to # again, study the new varabiles and rules CC-gcc CFLAGS=-g -Wall -std=c99 TARGETS-argshift squares make changes all: $ (TARGETS) #Static Pattern Rules $ (TARGETS): % : %"c $ (CC) (CFLAGS) -o e 2 #includeStep 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