Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

//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 #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 10 #include 12 //Implement the following function 13 //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 14 unsigned sum_n bytes(unsigned *p, int n) 16 17 18 //fill in your code below //Note that the sum should be an unsigned integer //This should has some ramifications on your code 19 /Only a few lines of code expected 20 21 23 25 26 27 28 29 30 31 //Note how we use the command line arguments 32 int main(int argc, char xargv[]) 34 if(argc!2) 35 36 37 38 39 printf("Usage: exit(-1) %s n ", argv[0]); intn-atoi (argv[1]); 37 38 39 40 41 42 43 44 45 46 47 48 49 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

10. What is meant by a feed rate?

Answered: 1 week ago