Write a c program that uses its first command line

Assignment Help Basic Computer Science
Reference no: EM131049682

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 <stdlib.h>

#include <stdio.h>

#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

Reference no: EM131049682

Questions Cloud

Create a notes and handouts header and footer : You are a student employee of your college's Student Success department. A previous employee created a presentation for students to view while they are waiting for their advisor.
Value of investment incorporating the tax shields : The WACC, APV and FTE methods determine the value of an investment incorporating the tax shields associated with leverage. However, some other potential imperfections are associated with leverage: Security mispricing, Financial distress and agency co..
How much must he set aside annually from until retirement : Arthur Anderson wants to retire in 15 years, and would like to put aside enough to give himself an income of $25,000 per year for 25 years after retirement. If he an earn 10% compounded annually over the whole time span and save and equal amount each..
When using the bond-yield-plus-risk-premium method : Root Stock Inc. is estimating its WACC. Its target capital structure is 20 percent debt, 20 percent preferred stock, and 60 percent common equity. Its bonds have a 12 percent coupon, paid semiannually, a current maturity of 20 years, and sell for $90..
Write a c program that uses its first command line : 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.
Considering leasing arrangement-straight-line basis : Redstone Corporation is considering a leasing arrangement to finance some special manufacturing tools that it needs for production during the next three years. A planned change in the firm's production technology will make the tools obsolete after 3 ..
Interest per month on the unpaid balance : If you buy a computer directly from the manufacturer for $3,050 and agree to repay in 36 equal installments at 1.72% interest per month on the unpaid balance, How much are your monthly payments?
Determining the mobile communication technique : In a congested city which of the following mobile communication technique would you use?
E-loan an online lending service : E-Loan, an online lending service, recently offered 36 month auto loans at 3.6% to applicants with good credit ratings. If you have a good credit rating and can afford monthly payments of $347, how much can you borrow from A-loan? What is the total i..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Travel guidebook from amazon

The Customer receives a Travel Guidebook from Amazon, then reads the book and chooses locations. The Customer also views locations on Google Maps using the Map Program as well as the Earth and Satellite Master files.

  What is the application/service date and applicable release

Does it provide a new application/service, replace an existing application/service, or enhance an existing application/service?

  Why is it impossible to represent x exactly in 32-bit ieee

Why is it impossible to represent X exactly in 32-bit IEEE ?oating-point? (b) and (c) What are the two binary numbers closest to X that we *can* represent?

  An investigation on the elements

At the point when directing an investigation on the elements, which add to a percentage of the issues shoppers experienced with the IPhone 6/6 or more, it was apparent that one of the memory chips was defective. This memory chip, fabricated by Samsun..

  Discuss the right of a corporate network administrator

Discuss the right of a corporate network administrator to use packet sniffers. Are employees' privacy rights being violated?

  Research job boards for project manager positions

Research job boards for project manager positions. Take note of the various industries that hire project managers. Then, research statistics from the project management institute on the rate of success of projects in different industries including..

  Store the corresponding indices in registers ax and bx

Store the corresponding indices in registers AX and BX respectively.

  Member functions for returning the monthly payment

Your loan class should have member functions for setting the loan amount, interest rate, and number of years of the loan. It should also have member functions for returning the monthly payment amount and the total amount paid to the bank at the en..

  Input controls

Explain the function of input controls.Identify four (4) types of input control and explain the function of each.

  Write the main program to generate random numbers

To compare the performance, you need to write the main program to generate random numbers to populate a large integer array, and then call the subroutine to sort this array. Remember to get the time before and after the bubble sort to measure the ..

  Moral dilemma and the decision made

Write a 2-3 page paper that describes a personal experience involving an ethical or moral dilemma and the decision made. What were the implications.

  Security threat report

Determine whether or not you believe that the mobile device threats are the most critical and disturbing of all of the security threats presented in the articles. Provide a rationale for your response.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd