Lab 2 Solution

$29.99 $18.99

The purpose of this lab is to practice writing C programs involving pointers and the scanf function. To start, log in to MarkUs and navigate to the lab2 assignment. Like the previous lab, this triggers the starter code for this lab to be committed to your repository. We’ve described each problem briefly below, but for…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product

The purpose of this lab is to practice writing C programs involving pointers and the scanf function.

To start, log in to MarkUs and navigate to the lab2 assignment. Like the previous lab, this triggers the starter code for this lab to be committed to your repository. We’ve described each problem briefly below, but for more detail on the first two problems, read through the starter code. There is no starter code for the final two problems.

Your task is to implement a function invest that takes an amount of money and multiplies it by a given rate. It’s your job to figure out the exact type of this function’s arguments, given the sample usage in the main function in the starter code.

Your task is to implement a function sum_card , which takes an array of pointers to integers, and returns the sum of the integers being pointed to.

Your task is to write a small C program called phone.c that uses scanf to read two values from standard input. The first is a 10 character string and the second is an integer. The program takes no command-line arguments.

If the integer is -1, the program prints the full string to stdout. If the integer is between 0 and 9 the program prints only the corresponding digit from the string to stdout. In both of these cases the program returns 0.

If the integer is less than -1 or greater than 9, the program prints the message “ERROR” to stdout and returns 1.

We haven’t learned about strings yet, but you will see that to hold a string of 10 characters, you actually need to allocate space for 11 characters. The extra space is for a special character that indicates the end of the string. Use this line

char phone[11];

to declare the variable to hold the string. Other than this line, there is no starter code for this program.

2页 共2 2019/3/23 14:07