• Keine Ergebnisse gefunden

Save your source code asscalarproduct.cinto the directoryserie03

N/A
N/A
Protected

Academic year: 2021

Aktie "Save your source code asscalarproduct.cinto the directoryserie03"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Dirk Praetorius, Sommersemester 2018

Gregor Gantner 20.03.2018

Ubungen zur Vorlesung¨

Einf¨uhrung in das Programmieren f¨ur TM Serie 3

Aufgabe 3.1. Write a function scalarproduct which computes and returns the scalar productw = u·v:=ax+by+cz of two given vectorsu= (a, b, c)T and v= (x, y, z)T. Furthermore, write a main program which reads the parametersa, b, c, x, y, z from the keyboard and prints to the screen the value of the scalar product. Save your source code asscalarproduct.cinto the directoryserie03.

Aufgabe 3.2. Write a void function vectorproduct, which, given two vectors u = (a, b, c)T and v= (x, y, z)T, computes and prints to the screen the vector productw=u×vdefined by

w1=bz−cy w2=cx−az w3=ay−bx.

Then, write a main program which reads the entries of the vectorsu,vfrom the keyboard and calls the function. Save your source code asvectorproduct.cinto the directoryserie03.

Aufgabe 3.3. Write a void-functiondivisor which checks if a given number x ∈ N:= {1,2,3, . . .} is divisible by 2, 3, or 6. Additionally, write a main program that reads in the number x, then calls the functiondivisor, and prints out the result. Save your source code as teiler.cinto the directory serie03.

Aufgabe 3.4. Write a void-function curve sketching which does a curve sketching for a quadratic function p(x) = a+bx+cx2 with coefficients a, b, c ∈ R. If existing, compute the extremum (and which kind of extremum it is). Additionally, if existing, compute the roots of the function. Otherwise, print on the screen, that the function does not have an extremum resp. roots. Moreover, write a main program which reads in the parameters a, b, c and which calls the function. Save your source code as curve sketching.cinto the directoryserie03.

Aufgabe 3.5. Write avoid-functionmoneythat calculates given an amount of moneyn∈Nthe minimal number of bank notes (500e, 100e, 50e, 20e, 10e, 5e) resp. coins (2e, 1e) such that the sum equals the value ofn. This number shall be displayed on the screen. For example, forn= 351, one should get the following output

3 x 100 EUR 1 x 50 EUR 1 x 1 EUR

Write a main program which reads the valuen∈Nand which calls the functionmoney. Save your source code asmoney.cinto the directoryserie03.

Aufgabe 3.6. Write a function minabs that, given two numbers x, y ∈ R, returns the one with the smallest absolute value. The mathematical library must not be used. Then, write a main program, which readsxandy from the keyboard and prints a message with the result of the function. Save your source code asminabs.cinto the directoryserie03.

Aufgabe 3.7. Write a functionpoints which, given three points (x, y), (u, v), and (a, b) inR2, checks whether they lie on the same line. Moreover, write a main program which reads the six coordinates of the points from the keyboard and prints out the result on the screen. Save your source code aspoints.c into the directoryserie03.

(2)

Aufgabe 3.8. Write a recursive function division, which computes and returns the result of the integer division m/n (division without remainder) of two given integers m ≥ 0 und n > 0. Only the arithmetic operations+and-can be used by the function. Moreover, write a main program which reads mand nfrom the keyboard and print the result m/nto the screen.Hint: For any y6= 0, it holds that x/y= 1 + (x−y)/y. Save your source code asdivision.c into the directoryserie03.

Referenzen

ÄHNLICHE DOKUMENTE

The City of Stuttgart – together with its universi- ties, regional business and development partners, and the local Em- ployment Agency – wants to ease your transition

Bitte geben Sie Ihren vollen Na- men, die vollständige Adresse und für Rück- fragen auch immer Ihre Telefonnummer an.

In contrast to the usual indexing in C (e.g., the indexing considered in the lecture), let the indices for the matrix entries a jk of your structure SquareMatrix go from j, k = 1 to

Write a function int anagram(char* firstStr, char* secondStr) which checks if a given word is an anagram of a second given word.. An anagram of a word is a letter sequence which

Write a main program, which reads the vector x and its length n from the keyboard, sorts it with mergesort and prints to the screen the sorted vector.. Test your

Check via assert if b ≤ c Write a main program which reads in the bounds and calls the function armstrong.. How did you test the correctness of

Additionally, write a main program that reads in the number x, then calls the function divisor, and prints out the result.. Save your source code as teiler.c into the

Assume that an average of 4 marked exercises per EPROG exercise class yields 22.5 points and an average of 7 yields 37.5 points for the computation of your final grade (without