Write a program that finds either the largest or smallest

Assignment Help C/C++ Programming
Reference no: EM132076057

You need help with the following two programs.

Question 1. Write a program to remove a comment starting with /* and ending with */ in a statement, which is entered by the user. If the input does not contain a comment, the program should leave the statement as it is.

Input: int i; /*declare integer variable i*/ Output: int i; Input: int i; Out: int i;

Your program should include the following function:

void remove_comment(char *s1, char *s2);

The function expects s1 to point to a string containing the input as a string and stores the output to the string pointed by s2.

1) Name your program remove.c.

2) Assume input is no longer than 100 characters. Assume the input contains no more than one /*...*/ comment.

3) The remove_comment function should use pointer arithmetic (instead of array subscripting). In other words, eliminate the loop index variables and all use of the [] operator in the function.

4) To read a line of text, use the read_line function (the pointer version) in the lecture notes.

Question 2. Write a program that finds either the largest or smallest of the ten numbers as command-line arguments. With -l for largest and -s for smallest number, if the user enters an invalid option, the program should display an error message.
Example runs of the program:

./find_largest_smallest -l 5 2 92 424 53 42 8 12 23 41 output: The largest number is 424 ./find_largest_smallest -s 5 2 92 424 53 42 8 12 23 41 output: The smallest number is 2
1) Name your program numbers.c.

2) Use atoi function in <stdlib.h> to convert a string to integer form.

3) Generate the executable as find_largest_smallest.

gcc -Wall -o find_largest_smallest numbers.c

Reference no: EM132076057

Questions Cloud

Prepare a comprehensive report directed to an australian : Students are required to prepare a comprehensive report directed to an Australian ASX Top 100 listed corporation detailing a critical analysis
Internet effect on public opinion : Write a paper that summarizes how the Internet may affect public opinion in a positive or negative way with regards to brand reputation.
What does the national organ transplant act : 1. What does the National Organ Transplant Act (NOTA) regulate and what does it not regulate?
Produce a short report by investigating and advising company : This assessment item requires you to produce a short report by investigating and advising a company on some key topics and aspects of the use of virtualisation
Write a program that finds either the largest or smallest : Write a program that finds either the largest or smallest of the ten numbers as command-line arguments.
Calculate the mean access time to four decimal digits : You have a 2-level cache. Level 1 cache is 1MB and level 2 cache is 2MB. Level 1 cache has a mean access time of 20 nsec, level 2 200 nsec.
Define and explain the concept of the terminologies : Define and explain the concept of the following terminologies: Electronic Records Management; Business intelligence (BI) and Analytics;
Design and write a base e and three derived classes : Design and write a base e and three derived classes that inherit from the base (similar to the shape class and the derived shape base asses).
Write a recursive function that takes one parameter : Write a recursive function that takes one parameter n (n>0) of type int and returns

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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