Question: PROGRAMMING LANGUAGE C Objectives: 1. Use functions 2. Use while/for loop 3. Use if/switch statements 4. Work with input and output 5. Work with arrays

PROGRAMMING LANGUAGE C

Objectives:

1. Use functions

2. Use while/for loop

3. Use if/switch statements

4. Work with input and output

5. Work with arrays

EXERCISE 1

(common.c) Write a program repeatedly read two numbers from user and output the greatest common divisor , least common multiple and weather or not they are coprime.

Specific Requirement:

- You are required to declare, define and call function gcd(num1, num2), lcm(num1, num2) and coprime(num1, num2). Function coprime() should call gcd().

Program output should look like this. Type ctrl^c to end it:

PROGRAMMING LANGUAGE C Objectives: 1. Use functions 2. Use while/for loop 3.

EXERCISE 2

(subseq.c) Write a program to find the longest continuous increasing subsequence. For example, if the input is [1,3,5,4,7], The longest continuous increasing subsequence is [1,3,5]. Even though [1,3,5,7] is also an increasing subsequence, it's not a continuous one where 5 and 7 are separated by 4. If the input is [2,2,2,2,2], the longest continuous increasing subsequence is [2], its length is 1.

In your program, the user will enter data ended with -1. The number of data is no more than 30. Your program should print the index range of the longest

subsequence, followed by the accrual data, followed by the sequence size.

For example, if user enters 1 3 5 4 7 -1, You program should print: [0..2]:[1,3,5]:3

Please follow the above print format exactly. The data should be separated with ,. There is no comma (,) after the last number. If there are multiple increasing subsequence with same length, the first one from left should be reported.

Example of outputs:

Use if/switch statements 4. Work with input and output 5. Work with

EXERCISE 3

(wordsearch.c) Given some character input (maximum 1000 chars) ended with new line, and a word to be searched (maximum 20 chars) ended with new line, search for the appearance of the word in the input text forward and backward. Print the beginning index for all matches. For example, if the search text is never odd or even and the search word is eve

arrays EXERCISE 1 (common.c) Write a program repeatedly read two numbers from

user and output the greatest common divisor , least common multiple and

please enter two positive integers:3 4 lcm(3,4)-12, gcd(3,4)-1, coprime(3,4)-Yes please enter two positive integers: 12 10 lcm(12,10)-60, gcd (12,10)-2, coprime (12,10) No please enter two positive integers : 75 50 lcm(75,50)-150, gcd (75,50)-25, coprime (75,50) No please enter two positive integers: C

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!