Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Programming Assignment

Topics: Arrays in C.

For this assignment, you will write a C program that uses its first command line parameter to compute and display a histogram of characters that occur in it.

Requirements:

  • Your program must compile and run correctly using the gcc compiler on ale.
  • You must write the corresponding function definitions for the following function prototypes:

// set all elements of the histogram to zero

void init_histogram(int histo[]);

// construct the histogram from string

void cons_histogram(char string[], int histo[]);

// display the histogram to the screen in a "nice" format

void display_histogram(int histo[]);

  • Your functions must work with the following program:

#include

#include

#define MAX_CHAR 255 // largest ASCII(Extended) value for characters

typedef unsigned char byte; // may be useful for casting(s)

void init_histogram(int histo[]);

void cons_histogram(char string[], int histo[]);

void display_histogram(int histo[]);

int main(int args, char *argv[])

{

  int histo[256];

  if (args == 2)

  {

    init_histogram(histo);

    cons_histogram(argv[1], histo);

    display_histogram(histo);

  }

  else

    exit(1);

  return 0;

}

void init_histogram(int histo[])

{

  // your code here

}

void cons_histogram(char string[], int histo[])

{

  // your code here

}

void display_histogram(int histo[])

{

  // your code here

}

Outline:

  • Create / open a .c file using pico, in your UNIX account

1. Write the necessary C statementss to meet the game specification given above

  • Make sure to test your "program" when it is done

2. You really need to run your program a number of time to do this thoroughly

Notes(s):

  • Only those characters that occurred at least once are reported.
  • The minimal occurrence may very well not be unique.
  • The value of a char variable is an integer value and hence can be used as an index into the histogram - once casted as unsigned to be safe.

Sample Run(s):

% ./a.out hgfjkddjkrui3

3 appeared 1 time

d appeared 2 times

f appeared 1 time

g appeared 1 time

h appeared 1 time

i appeared 1 time

j appeared 2 times

k appeared 2 times

r appeared 1 time

u appeared 1 time

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91774103
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Determine the mass of the water by using the waters density

Determine the mass of the water by using the water's density (specific to the initial temperature) and the volume of the water. Remember,  density = mass/volume . You can look up the density of the water at your specific ...

The task is to implement closest pair algorithm along with

The task is to implement closest pair algorithm. Along with the implementation in c++, I want two additional things. Thing 1. Test the correctness of your algorithm in the following way: Generate 100 random points in the ...

Seamus was assigned to created web site plan for a charity

Seamus was assigned to created Web site plan for a charity organization. He must ensure that the site includes the following features: -A message stating the purpose of the charity -An online form that will receive perso ...

Recall the successor notation for representing natural

Recall the successor notation for representing natural numbers as terms in Prolog. In this notation, "0" stands for the number zero, "s (0)" stands for one, "s (s (0))" stands for two, and so on. (a) Based on the success ...

Question what sequence of numbers would be printed by the

Question : What sequence of numbers would be printed by the following recursive function if we started it with N assigned the value 1? def Exercise (N): print(N) if (N Exercise(N + 1) print(N)

A sample of 40 songs from a students itunes playlist showed

A sample of 40 songs from a student's iTunes playlist showed a mean length of 3.542 minutes with a standard deviation of 0.311 minute. Construct a 95% confidence interval for the population standard deviation.  (Round yo ...

Taskwrite an essay according to the following

Task Write an essay according to the following instructions. Your lecturer will provide few links for relevant articles and/or case studies. These will be available to you just after your second assignment submission dat ...

Sql transactions exercisesperform the test for the

SQL Transactions Exercises Perform the test for the non-additive join property (lossless join) for the relation R(A 1 , A 2 , A 3 , A 4 , A 5 ), and the decompositions D a , D b , D c , D d  and set of functional depende ...

Please discuss the followingas demand increased for these

Please discuss the following: As demand increased for these mortgage backed securities, lenders reacted by relaxing their approval standards to increase production. No longer were "all" borrowers required to document the ...

Technology certainly does play a large role in our lives

Technology certainly does play a large role in our lives and this has happened in a very short period of time. It has impacted the way we activities professionally, personally, and academically. For example, online educa ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As