Eeo 224 object-oriented programming for electrical and


Assignment

Question 1. Write a program that reads a char as input, and determines if it is a lowercase letter, up¬percase letter, a digit or something else (call this a special character).

Question 2. The Taylor series expansion for the exponential function, for small values of x is given by:

ex = 1 + x + x2/2! + x3/3! + . . .

Write a program that takes as input the value of x (for example 0.01), and computes ex using the above approximation. The program should sum up n terms, and stop when the value of the nth term is less than a predefined constant accuracy, set to 0.00001.

Question 3. Write a program to generate m random integers from an array of size n, such that the probability of selecting even indexed elements is twice that of odd indexed elements. The same element may be selected multiple times. As an example, let n = 100 and m = 30. Read in the array elements from the provided data file ArrayInp.dat, using the fscanf() func¬tion. Utilize the function rand() to generate a pseudo random number and the function srand() to seed the random number generator. Start with the code RandomArrayGen¬erate.c provided on the Blackboard.

Question 4. Design an algorithm, and write the code to find all pairs of integers in a sorted array, which sum up to a specified value. For example, if the given array is

int arrN[10] = {1, 3, 7, 14, 22, 35, 44, 45, 46, 53};

and the specified sum is 49, the output would be:
3 46
14 35

The algorithm should work well for very large array sizes.

Question 5. Write a program that initializes an array, and prints out its elements using the pointer no¬tation and pointer incrementing.

Question 6. In the file Cauchy.dat provided on the Blackboard, find all occurrences of the word mathematician. For reading the data from the input file, you can use the fscanf() function with the %s specifier. Utilize the string function strncmp() for string comparison.

Attachment:- data files.zip

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Eeo 224 object-oriented programming for electrical and
Reference No:- TGS02644574

Now Priced at $70 (50% Discount)

Recommended (92%)

Rated (4.4/5)