Question

I need the pseudocode for this c program source code. #include<stdio.h> void printarray(int array[], int asize){...

I need the pseudocode for this c program source code.

#include<stdio.h>
void printarray(int array[], int asize){
int i;
for(i = 0; i < asize;i++)
printf("%d", array[i]);
printf("\n");
}
int sum(int array[], int asize){
int result = 0;
int i = 0;
for(i=0;i < asize;i++){
result = result + array[i];
}
return result;
}
int swap( int* pA,int*pB){
int result = 0;
if(*pA > pB){
int tamp = *pA;
*pA = *pB;
*pB = tamp;
result = 1;
}
return result;
}
int sort_1pass(int array[], int asize){
int result = 0;
int i;
for(i=0;i < asize-1;i++){
result = result + swap(&array[i], &array[i+1]);
}
return result;
}
void sort(int array[],int asize){
int result = 1;
while(result!=0){
result = 0;
result = sort_1pass(array, asize);
printarray(array, asize);
}
}

int main(){
int array[] ={8,1,8,2,0,3,1,9,8};
int size = 9;
printarray(array, size);
printf("The sum is%d\n", sum(array, size));
sort(array, size);
printf("The median is: %d\n", array[size / 2]);
printf("The average is %0.2lf\n",(double)sum(array, size)/size);
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Pseudocode:
   1. Declare and initialize an array of type int with some values name it array.
   2. declare an int variable size which represents the total number of elements present in an array.
   3. Define a function printarray with parameters of an int array and int variable.Implement this function for printing the array.
   4. Call the above implemented function.
   5. Define a function sum with parameters of an int array and int variable.Implement this function for calculating the sum of elemets present in array.
   6. Call the above implemented function and print the result.
   7. Implement a sort function which will sort the array.
   8. Call above implemented function for sorting the array.
   9. Print the middle element of an array as a median of array.
   10. Calculate the average of the array by caluclating the sum and dividing the sum by size and print the result.

Add a comment
Know the answer?
Add Answer to:
I need the pseudocode for this c program source code. #include<stdio.h> void printarray(int array[], int asize){...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm trying to code a C program so it sorts an array of integer numbers of...

    I'm trying to code a C program so it sorts an array of integer numbers of size n in ascending order. My code is written below but its not working properly, its giving me errors, I think my sort and swap functions aren't done right maybe, please help and fix. It says "undefined reference to "SelectionSort" as an error. But the question asks to not change the PrintArray and Main function. #include <stdio.h> void PrintArray(int size, int array[]) { for...

  • sort.c #include <stdlib.h> #include <stdio.h> #include "libsort.h" int main() {     int* array;     int size,...

    sort.c #include <stdlib.h> #include <stdio.h> #include "libsort.h" int main() {     int* array;     int size, c;     float median;     printf("Enter the array size:\n");     scanf("%d", &size);     array = (int*) malloc(size * sizeof(int));     printf("Enter %d integers:\n", size);     for (c = 0; c < size; c++)         scanf("%d", &array[c]);     sort(array, size);     printf("Array sorted in ascending order:\n");     for (c = 0; c < size; c++)         printf("%d ", array[c]);     printf("\n");     median = find_median(array,...

  • #include<stdio.h> #include<stdio.h> int main(){ int i; //initialize array char array[10] = {“Smith”, “Owen”, “Kowalczyk”, “Glass”, “Bierling”,...

    #include<stdio.h> #include<stdio.h> int main(){ int i; //initialize array char array[10] = {“Smith”, “Owen”, “Kowalczyk”, “Glass”, “Bierling”, “Hanenburg”, “Rhoderick”, “Pearce”, “Raymond”, “Kamphuis”}; for(int i=0; i<8;i++){ for(int j=0; j<9; j++){ if(strcmp(array[j],array[j+1])>0){ char temp[20]; strcpy(temp,array[j]); strcpy(array[j],array[j+1]); strcpy(array[j+1],temp); } } } printf(“---------File Names---------\n”); for(inti=0; i<9; i++){ printf(“\t%s\n”,array[i]); } printf(-------5 Largest Files according to sorting----\n”); for(int i=0;i>=5;i--) { printf(“\t%s\n”,array[i]); } return0; } Consider the "sort" program (using with void* parameters in the bubblesort function) from the week 10 "sort void" lecture. Modify it as follows...

  • i need flowchart for the following c code #include <stdio.h> int main() {     int n,...

    i need flowchart for the following c code #include <stdio.h> int main() {     int n, i, sum = 0;     printf("Enter an integer: ");     scanf("%d",&n);     i = 1;     while ( i <=n )     {         sum += i;         ++i;     }     printf("Sum = %d",sum);     return 0; }

  • Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int...

    Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int *); void replaceAt(int *, int, int); int isEmpty(int *, int); int isFull(int *, int); void removeAt(int *, int); void printList(int *, int); int main() { int *a; int arraySize=0,l=0,loc=0; int choice; while(1) { printf("\n Main Menu"); printf("\n 1.Create list\n 2.Insert element at particular position\n 3.Delete list.\n4. Remove an element at given position \n 5.Replace an element at given position\n 6. Check the size of...

  • Complete this program in C #include<stdio.h> int main(void) { int sumA(__, __); int answer;   //the two...

    Complete this program in C #include<stdio.h> int main(void) { int sumA(__, __); int answer;   //the two parameters are start and end addresses of intA[] answer = sumA(......); printf("..........", intA); printf("The sum of integers in intA is %d.\n", answer); return 0; } //the two parameters of sumA(__, __) are start and end addresses of intA[] int sumA(..........) { ……………………. return ............. }

  • 1.Write code for a Java method, printArray, that takes an int array as parameter and prints...

    1.Write code for a Java method, printArray, that takes an int array as parameter and prints it out, one element per line. public static void printArray (int[] values){ Methods that do NOT return a result have “void” as return type. Notice how an array parameter type is passed, int [] }// end printArray 2.Write code for a Java method that takes in as input parameter an integer number, say num, and returns a double array of size num with all...

  • I need some with this program, please look at the changes I need closely. Its running...

    I need some with this program, please look at the changes I need closely. Its running correctly, but I need to do a few adjustments here is the list of changes I need: 1. All of the integers on a single line, sorted in ascending order. 2. The median value of the sorted array on a single line 3. The average of the sorted array on a single line Here is the program: #include<stdio.h> #include<stdlib.h> /* This places the Adds...

  • c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each...

    c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each size Im trying to do time analysis for Quick sort but i keep getting time = 0 also i want edit the program to test different random sizes of the array and give me the time in a...

  • #include "stdio.h" int main() { float array[5][3],rowsum=0.0,colsum=0.0; int i,j; for(i=0;i<5;i++){ printf("Enter the %d elements of array:\n",i);...

    #include "stdio.h" int main() { float array[5][3],rowsum=0.0,colsum=0.0; int i,j; for(i=0;i<5;i++){ printf("Enter the %d elements of array:\n",i); for(j=0;j<3;j++){ scanf("%f",&array[i][j]); } } printf("Given table data:\n"); for(i=0;i<5;i++){ for(j=0;j<3;j++){ printf(" %0.1f",array[i][j]); } printf("\n"); } for(i=0;i<5;i++){ for(j=0;j<3;j++){ rowsum=rowsum+array[i][j]; } printf("sum of the %d row is %0.1f\n",i,rowsum); rowsum=0; } for(j=0;j<3;j++){ colsum+=array[j][i]; printf("Sum of %d coloumn is %0.1f\n",j,colsum); colsum=0; } return(0); } can someone help me to get the correct row sum and column sum in c program

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT