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

Lehrmaterialien, Beispiel-Programme und Übungsaufgaben 29.10.2018

parent daaabdb1
Branches
No related tags found
No related merge requests found
Showing
with 195 additions and 0 deletions
#include <stdio.h>
int main (void)
{
char h[] = "Hello!\n";
h[1] = 'a';
printf ("%s", h);
return 0;
}
#include <stdio.h>
int main (void)
{
char *h = "Hello!\n";
while (*h)
printf ("%c", (*h)++);
return 0;
}
#include <stdio.h>
int main (void)
{
char *h = "Hello!\n";
h[1] = 'a';
printf ("%s", h);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = "Hello!\n";
char *h = hello;
h[1] = 'a';
printf ("%s", h);
return 0;
}
#include <stdio.h>
int main (void)
{
char h[] = "Hello!\n";
int i = 0;
while (h[i])
printf ("%c", h[i++]);
return 0;
}
#include <stdio.h>
int main (void)
{
char *h = "Hello!\n";
int i = 0;
while (h[i])
printf ("%c", h[i++]);
return 0;
}
#include <stdio.h>
int main (void)
{
char h[] = "Hello!\n";
printf ("%c\n", *h);
return 0;
}
#include <stdio.h>
int main (void)
{
char h[] = "Hello!\n";
while (*h)
printf ("%c", *h++);
return 0;
}
#include <stdio.h>
int main (void)
{
char h[] = "Hello!\n";
while (*h)
printf ("%c", (*h)++);
return 0;
}
#include <stdio.h>
int main (void)
{
char h[] = "Hello!\n";
while (*h)
printf ("%c", *h + 1);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Der Buchstabe lautet: %c\n", 1117);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Der Buchstabe lautet: %c\n", 1117);
printf ("Die Zahl lautet: %d\n", ']');
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Der Buchstabe lautet: %c\n", 1117);
printf ("Die Zahl lautet: %d\n", ']');
printf ("Der Buchstabe als Hexadezimalzahl lautet: %x\n", 1117);
printf ("Die Zahl in hexadezimal lautet: %x\n", ']');
return 0;
}
int fun_1 (char *s1, char *s2)
{
int result = 1;
for (int i = 0; s1[i] && s2[i]; i++)
if (s1[i] != s2[i])
result = 0;
return result;
}
#include <stdio.h>
int main (void)
{
int n, i, divisors;
for (n = 0; n < 100; n++)
divisors = 0;
for (i = 0; i < n; i++)
if (n % i == 0)
divisors++;
if (divisors = 2)
printf ("%d ist eine Primzahl.\n", n);
return 0;
}
Hello, world!
#include <stdio.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
fprintf (f, "Hello, world!\n");
fclose (f);
return 0;
}
#include <stdio.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
}
return 0;
}
#include <stdio.h>
#include <errno.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
}
else
fprintf (stderr, "error #%d\n", errno);
return 0;
}
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main (void)
{
FILE *f = fopen ("fhello.txt", "w");
if (f)
{
fprintf (f, "Hello, world!\n");
fclose (f);
}
else
{
char *msg = strerror (errno);
fprintf (stderr, "%s\n", msg);
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment