Skip to content
Snippets Groups Projects
Commit a6ce6cb3 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Lehrmaterialien und Beispiele 15.10.2018

parent 5339445d
No related branches found
No related tags found
No related merge requests found
Showing
with 1489 additions and 0 deletions
#include <stdio.h>
int answer (void)
{
return 42;
}
void foo (void)
{
printf ("%d\n", answer ());
}
int main (void)
{
foo ();
return 0;
}
#include <stdio.h>
int a = 0;
int b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
}
#include <stdio.h>
int a = 0;
int b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
return 0;
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
}
#include <stdio.h>
int a = 0;
int b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
}
#include <stdio.h>
int a = 0;
int b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
}
#include <stdio.h>
int a = 0;
int b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
return 0;
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
}
#include <stdio.h>
int a = 0;
int b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
}
#include <stdio.h>
int answer (void)
{
return 42;
}
void foo (void)
{
printf ("%d\n", answer);
}
int main (void)
{
foo ();
return 0;
}
#include <stdio.h>
int answer (void)
{
return 42;
}
void foo (void)
{
printf ("%d\n", answer ());
}
int main (void)
{
foo;
return 0;
}
#include <stdio.h>
void add_verbose (int a, int b)
{
printf ("%d + %d = %d\n", a, b, a + b);
}
int main (void)
{
add_verbose (3, 7);
return 0;
}
#include <stdio.h>
void main (void)
{
printf ("Hello, world!\n");
}
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 137;
}
#include <stdio.h>
int add_verbose (int a, int b)
{
printf ("%d + %d = %d\n", a, b, a + b);
return a + b;
}
int main (void)
{
add_verbose (3, 7);
return 0;
}
#include <stdio.h>
int a, b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
}
#include <stdio.h>
int a;
int b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
return 0;
}
20181015/gitlab.png

757 B

File added
This diff is collapsed.
File added
% hp-uebung-20181015.pdf - Exercises on Low-Level Programming / Applied Computer Sciences
% Copyright (C) 2013, 2015, 2016, 2017, 2018 Peter Gerwinski
%
% This document is free software: you can redistribute it and/or
% modify it either under the terms of the Creative Commons
% Attribution-ShareAlike 3.0 License, or under the terms of the
% GNU General Public License as published by the Free Software
% Foundation, either version 3 of the License, or (at your option)
% any later version.
%
% This document is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this document. If not, see <http://www.gnu.org/licenses/>.
%
% You should have received a copy of the Creative Commons
% Attribution-ShareAlike 3.0 Unported License along with this
% document. If not, see <http://creativecommons.org/licenses/>.
% README: Fibonacci-Zahlen, fehlerhaftes Programm, "Hello, world!"
\documentclass[a4paper]{article}
\usepackage{pgscript}
\thispagestyle{empty}
\begin{document}
\thispagestyle{empty}
\section*{Hardwarenahe Programmierung / Angewandte Informatik\\
Übungsaufgaben -- 15.\ Oktober 2018}
\exercise{Fibonacci-Zahlen}
Die Folge der Fibonacci-Zahlen ist definiert durch:
\begin{quote}
1.\ Zahl: 0\\
2.\ Zahl: 1\\
nächste Zahl = Summe der beiden vorherigen
\end{quote}
Schreiben Sie ein Programm, das die ersten 50 Fibonacci-Zahlen ausgibt.
\exercise{Fehlerhaftes Programm}
Wir betrachten das folgende C-Programm
(Datei: \gitfile{hp}{20181015}{aufgabe-2.c}):
\begin{lstlisting}
#include <stdio.h>
int main (void)
{
for (int i = 10; i = 0; i - 1)
printf ("%d\n", i);
return 0;
}
\end{lstlisting}
\begin{itemize}
\item[(a)]
Was bewirkt dieses Programm und warum?
\item[(b)]
Ändern Sie das Programm so, daß es einen "`Countdown"' von 10 bis 0 ausgibt.
\end{itemize}
\exercise{Hello, world!}
Unter \url{https://gitlab.cvh-server.de/pgerwinski/hp/tree/master/20171016}
finden Sie (unter anderem)\\
die Programme \gitfile{hp}{20181015}{test-1.c},
\gitfile{hp}{20181015}{test-2.c} und \gitfile{hp}{20181015}{test-3.c}.
Was bewirken diese Programme, und warum verhalten sie sich so?
\end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment