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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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