Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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:

image text in transcribed

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

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago