Table processing and pointers
User Generated
wrssawb
Programming
Description
The C program below receives integers as command line arguments. After
receiving the required values, the program calls the subroutine
"calculate_and_print" which receives an array and its size passed by the
main program, prints the numbers on the screen and prints their sum on
the screen.
#include <stdio.h>
#include <stdlib.h>
void calculate_and_print(int *, int);
/*The task is to write the subroutine "calculate_and_print". This part of the code need to be fixed*/
int main(int argc, char *argv[])
{
int x, sum=0, size=5, array[5];
if(argc == 6){
/* Program name and command line parameters */
for(x=0;x<argc-1;x++){
array[x] = atoi(argv[x+1]);
}
calculate_and_print(array, size);
}else{
printf("Incorrect number of command line arguments\n");
}
return 0;
}
T
This question has not been answered.
Create a free account to get help with this and any other question!
24/7 Homework Help
Stuck on a homework question? Our verified tutors can answer all questions, from basic math to advanced rocket science!
Similar Content
Related Tags
Ezperanza Rising
by Pam Muñoz Ryan
The Goldfinch
by Donna Tartt
I Cant Make This Up - Life Lessons
by Kevin Hart
100 Side Hustles
by Chris Guillebeau
Rules Of Civility
by Amor Towles
The Secret Garden
by Frances Hodgson Burnett
Dr Jekyll And Mr Hyde
by Robert Louis Stevenson
The Calcutta Chromosome
by Amitav Ghosh
My Brilliant Friend
by Elena Ferrante