Question

This is all the information that I have.

This is all the information that I have.
media%2F7e1%2F7e18636b-9192-4966-9cf4-c1
media%2F482%2F4823d342-eadb-459e-a284-1b
0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you find this helpful, then please leave a like.

CODE:

#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE *fin;
int n,*arr,*arrcopy,i,j,temp,cnt;
fin=fopen("numbers.txt","rt"); //Opening file
fscanf(fin,"%d",&n); //Extracting number of values in dataset
while(n!=0)
{
//Creating dynamic arrays
arr=(int*)malloc(n*sizeof(int));
arrcopy=(int*)malloc(n*sizeof(int));

//Reading values from file
for(i=0; i<n; i++)
{
fscanf(fin,"%d",&arr[i]);
arrcopy[i]=arr[i];
}

//Sorting
for(i=0; i<n-1; i++)
{
for(j=0; j<n-i-1; j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}

printf("\n Original Sorted\n");
for(i=0; i<n; i++)
printf("%*d %*d\n",9,arrcopy[i],9,arr[i]);
printf("\n Value Count\n");
i=0;

//Loop to find number of occurrences of a value
while(i<n)
{
temp=arr[i];
cnt=0;
while(i<n&&arr[i]==temp)
{
cnt++;
i++;
}
printf("%*d - %*d\n",9,temp,4,cnt);
}
  
//Deleting the dynamically created arrays
free(arr);
free(arrcopy);
fscanf(fin,"%d",&n);
}
fclose(fin);
return 0;
}

INPUTFILE:

num... File Edit Format View Help 4 8645 236 42 53 420 53 420 53

OUTPUT:

CAUsers Greenoe\ Documents Coding\Che.. Original Sorted 4 6 6 4 8645 236 8645 236 Value Count 4 6 236 - 8645 Original Sorted

Add a comment
Know the answer?
Add Answer to:
This is all the information that I have.
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
  • This is all of the information given. I have attached my data. This is from the...

    This is all of the information given. I have attached my data. This is from the Galileos pendulum lab. Use your graph to estimate the Q6 period of a pendulum that had aYour answer for Q6 here length of 2.00 meters.

  • i tried to start but think i have it all wrong. please help Required Information [The...

    i tried to start but think i have it all wrong. please help Required Information [The following information applies to the questions displayed below) In early January 2017 NewTech purchases computer equipment for $262,000 to use in operating activities for the next four years. It estimates the equipment's salvage value at $21000. Prepare a table showing depreciation and book value for each of the four years assuming double-declining balance depreciation. (Enter all amounts positive values.) End of Period Accumulated Depreciation...

  • it all information I have, thanks for helping Problem 39.28 t Random variables X and Y...

    it all information I have, thanks for helping Problem 39.28 t Random variables X and Y have joint distribution Y=011/15 | a | 2/15 Y-22/15a1/1i5 Let a be the value that minimizes the variance of X. Calculate the variance of Y

  • This is all the information that I have on the question, it's about making a drink...

    This is all the information that I have on the question, it's about making a drink more attractive to health-conscious people 1) We want to be able to offer the drink as a powder, which people can dissolve in water. Please advise on - should we have fine crystalline powder or a more coarse version? - is there a way to predict how fast a powder will dissolve? - can we have issues with the temperature? 2) We want to...

  • This was all that was given to me. I have no other information Suppose you have...

    This was all that was given to me. I have no other information Suppose you have a large, random sample of the variables Yand X. You then regress Yon Xand get the following results (with standard errors in parentheses) Y= 16.5-4.2X a. The numbers 16.5 and-4.2 are the realized values for the intercept and slope respectively) of the regression equation describing the sample, which are consistent estimators for what population parameters? The intercept and slope (respectively) of the sample determining...

  • Please help with all questions. I provided all the information that I have. The sequence below...

    Please help with all questions. I provided all the information that I have. The sequence below represents the genomic DNA sequence of the first 440 bp of your gene of interest (exon 1 in blue). You want to amplify this full 440 bp region by PCR, for cloning into a plasmid vector. tgaagtccaactcctaagccagtgccagaagagccaaggacaggtacggctgtcatcacttagacctcaccctgtggagccacaccctagggttggccaatctactcccaggagcagggagggcaggagccagggctgggcataaaagtcagggcagagccatctattgcttacatttgcttctgacacaactgtgttcactagcaacctcaaacagacaccatggtgcatctgactcctgaggagaagtctgccgttactgccctgtggggcaaggtgaacgtggatgaagttggtggtgaggccctgggcaggttgctatcaaggttacaagacaggtttaaggagaccaatagaaactgggcatgtggagacagagaagactcttgggtttctgataggcactgactctctctgcctattggtctattttcccaccc   1.1 Design a 20 nucleotide forward & reverse primer set that will allow you to amplify the sequence above. (note - primers should be at the beginning...

  • this is all the info i have i dont have any other information to provide please...

    this is all the info i have i dont have any other information to provide please answer ASAP 3.How do we define "quality" healthcare? a. Quality is based on a variety of criteria....but unfortunately we have not been able to identify a consistent and agreeable standard. b. Quality is equivalent to cost which is equivalent to Access. c. Cost per patient d. According to the Institute of Medicine, the quality of care provided by the U.S. healthcare delivery system is...

  • This is all the informaiton I have, If more information is needed like numbers, use random...

    This is all the informaiton I have, If more information is needed like numbers, use random ones. I just need an example to understand how to do the problem. 1. A capacitor is initially charged with a battery and then disconnect. At time t-0 the Value capacitor is connected to a 100,000 S resistor and begins to discharge. At each station in 1A. the room is a data table of 6 times and the voltage across the capacitor at those...

  • I need help with this QuickBooks information: I don’t have customers, but I do have donors...

    I need help with this QuickBooks information: I don’t have customers, but I do have donors and grants, how do I set them up if QuickBooks just has customers? We also now receive donations from Hanson Family trust. do we set them up as a customer? the info for the trust is...

  • i need help with this problem with all parts all the information its on that table...

    i need help with this problem with all parts all the information its on that table to help you find the answers. please i need it asap thank you Question Help Suppose you are holding the market portfollo shown in the table, EEB. and have invested $14,000 in Stock C. a. How much have you invested in Stock A? b. How many shares of Stock B do you hold? c. If the price of Stock C suddenly drops to $3...

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