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
please only edit this below code shown. any other form will not work
//In this assignment, we wirte code to sum up the values of the first n bytes in a memory block //that is allocated for n unsigned integers. //The memory allocation occurs in the main function //We need to implement the function sum_n_bytes //This function returns the sum of the values of the first n bytes that is pointed by //the pointer p
#include
//Implement the following function //The function sum_n_bytes returns the sum of the values of the first n bytes in the memory block//pointed by the pointer p unsigned sum_n_bytes(unsigned *p, int n) { //fill in your code below //Note that the sum should be an unsigned integer //This should has some ramifications on your code //Only a few lines of code expected
}
//Note how we use the command line arguments int main(int argc, char *argv[]) { if(argc != 2) { printf("Usage: %s n ", argv[0]); exit(-1); } int n = atoi(argv[1]); //allocate memory for n unsigned integers unsigned *p = calloc(n, sizeof(unsigned)); //Assign values to these unsigned integers in a certain pattern int i; for(i=0; i untitled sum n bytes.c x 1 //In this assignment, we wirte code to sum up the values of the first n bytes in a memory block 2 //that is allocated for n unsigned integers. 3 //The memory allocation occurs in the main function 4 //we need to implement the function sum_n_bytes 5 //This function returns the sum of the values of the first n bytes that is pointed by 6 //the pointer p 8 9 #include
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