

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CGS3460 Fall 2007 Assignment 7
Assigned: 10/6, Sat Due: 10/12, Fri
Write a C program that generates the seven-segment display for all digits from 0 to 9 and prints them one after another in a column. One way to implement this would be to use a 2-dimensional array to store what segments to turn on and what segments to turn off for each digit. This array would have 10 rows (one for each digit) and seven columns (one for each segment). You can number the segments in some order and then for each digit set the ith^ column to 1 if the ith segment is to be turned on, and otherwise set it to 0. While displaying, print the appropriate symbol or blank space depending on whether the segment is to appear “on” or “off”. Save this program in a file call p1.c.
The output for first 4 digits should be: (^) - | | | |-
| |
| |- |
not compromise the accuracy of your results. Save this program as p2.c. The problem statement is repeated here from the last assignment.
The exponential function, represented as ex, is one of the most important function in mathematics. The number e in the formula for exponential function is approximately equal to 2.71828 (in fact with this program you should be able to generate the value of e to a higher precision) and is also known as the Euler’s number. Interestingly, this function can also be computed using its power series, which is defined as following:
Here, the numbers in the denominators, m!, represent the factorial of the number m.
m! = 1 x 2 x 3 x … x m.
e.g. 3! = 1 x 2 x 3 = 6, 5! = 1 x 2 x 3 x 4 x 5 = 120.
Write a program that computes and displays the value of ex^ using its power series. User should enter the values of numbers x and n (the number of terms to use in the summation). Assume number x to be a floating point number. The number n governs the number of terms we want to include in our computation of the ex. Larger the n, better the accuracy. You can assume that user always enters a positive integer for n. Calculate and display your results to 10 decimal places. Round-off at the last decimal place is acceptable. A session with this program should be as follows:
Example 1: Enter value for x: 0 Enter value for n: 5 Value of exp(0.000000) = 1.0000000000.
Example 2: Enter value for x: 1 Enter value for n: 10 Value of exp(1.000000) = 2.7182817459.
Example 3: Enter value for x: 1. Enter value for n: 13 Value of exp(1.700000) = 5.4739475250.
Instructions for submitting Assignment 7