added ws202425 courses

This commit is contained in:
2024-11-14 13:11:04 +01:00
parent 800282c2e8
commit beb31897b1
461 changed files with 20368 additions and 0 deletions
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
#include <stdio.h>
int main(void){
for(int i = 12; i >= 0; i-=2){
printf("%i, ",i);
}
printf("\n");
for(int i = -1; i >= -13; i-=2){
printf("%i, ", i);
}
printf("\n");
for(int i = 0; i <= 9; i++){
printf("%i, ", i*i);
}
}
@@ -0,0 +1,37 @@
/* formatelemente.c
*
* ACHTUNG: Enthaelt Fehler, die Sie bereinigen sollen!
*
*/
#include <stdio.h>
int main(){
int i = 66;
double x = .000007;
double y = 123.45;
/* Printing the integer 'i' in various formats
%d prints the integer in decimal format
%o prints the integer in octal format
%x prints the integer in hexadecimal (lowercase)
%X prints the integer in hexadecimal (uppercase)*/
printf("\ni:\n%d \n%o \n%x \n %X", i, i, i, i);
// Printing the double 'x' in various formats
// %f prints the double in fixed-point notation
// %e prints the double in scientific notation (lowercase 'e')
// %E prints the double in scientific notation (uppercase 'E')
// %g prints the double in either %f or %e, whichever is shorter, removing trailing zeros
// %G prints the double in either %f or %E, whichever is shorter, removing trailing zeros
printf("\nx:\n%f \n%e \n%E \n%g \n%G", x, x, x, x, x);
// Printing the double 'y' in a couple of formats
// %g prints the double in either %f or %e, depending on which is shorter, removing trailing zeros
// %G prints the double in either %f or %E, depending on which is shorter, removing trailing zeros
printf("\ny:\n%g \n%G\n", y, y);
// Print sentence
printf("Ich kenne die Formatelemente zu 100 %%.\n");
return 0;
}
@@ -0,0 +1,47 @@
#include <stdio.h>
#include <math.h>
int main() {
int i;
printf("\n");
for (i=12; i>=0; i=i-2) {
if (i==0){
printf("%d \n", i);
}
else {
printf("%d, ", i);
}
}
for (i=-1; i>=-13; i=i-2){
if (i==-13){
printf("%d \n", i);
}
else {
printf("%d, ", i);
}
}
for (i=0; i<=9; i++){
if (i == 9){
printf("%d \n", (int)pow(i,(double)2));
}
else{
printf("%d, ", (int)pow(i,(double)2));
}
}
for (i=0; i<=9; i++){
if (i==9){
printf("%d \n", i*i);
}
else{
printf("%d, ", i*i);
}
}
return 0;
}
@@ -0,0 +1,21 @@
/* formatelemente.c
*
* ACHTUNG: Enthaelt Fehler, die Sie bereinigen sollen!
*
*/
#include <stdio.h>
main()i {
int i = 66;
double x = .000007;
double y = 123.45;
printf("\ni:\n%d \n%o \n%x \n%X", i, i, i, i);
printf("\nx:\n%f \n%e \n%E \n%g \n%G", x, x, x, x, x);
printf("\ny:\n%g \n%G \n", y,y);
return 0;
}
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <math.h>
int main() {
int fahrenheit = 0;
int stepsize = 20;
int maxF = 300;
double celsius;
printf("\n%s %s %s \n", "Fahrenheit","Celsius (gerundet)","Celsius (exakt)");
while (fahrenheit <= maxF) {
celsius = (5.0/9.0) * (fahrenheit - 32);
printf("%d\t\t%d\t\t%f\n", fahrenheit, (int)celsius, celsius);
fahrenheit += stepsize;
}
return 0;
}
@@ -0,0 +1,8 @@
#include <stdio.h>
int main (){
printf("\n Ich kenn die Formatelemente zu 100%% \n");
return 0;
}
@@ -0,0 +1,39 @@
/* typengroesse.c
*
* Bestimmung der Groesse der einfachen typen mit sizeof
*/
#include <stdio.h>
int main() {
char c = 127;
unsigned char uc = 255;
printf("\n");
//Ganzzahltypen
printf("char: \t\t%2d\n", (int) sizeof c);
printf("uns. char: \t%2d\n", (int) sizeof uc);
printf("short: \t\t%2d\n", (int) sizeof (short));
printf("uns. short: \t%2d\n", (int) sizeof (unsigned short));
printf("int: \t\t%2d\n", (int) sizeof (int));
printf("uns. int: \t%2d\n", (int) sizeof (unsigned int));
printf("long: \t\t%2d \n", (int) sizeof (long));
printf("uns. long: \t%2d \n", (int) sizeof (unsigned long));
printf("long long: \t%2d \n", (int) sizeof (long long));
printf("uns. long long: %2d \n", (int) sizeof (unsigned long long));
// Gleitpunkttypen
printf("float: \t\t%2d\n", (int) sizeof (float));
printf("double: \t%2d\n", (int) sizeof (double));
printf("long double: \t%2d\n", (int) sizeof (long double));
printf("\n");
return 0;
}
@@ -0,0 +1,45 @@
#include <stdio.h>
#include <math.h>
int main(){
int i;
printf("\n");
i=12;
while(i>=0){
if (i==0){
printf("%d \n", i);
}
else {
printf("%d, ", i);
}
i=i-2;
}
i=-1;
do{
if (i==-13){
printf("%d \n", i);
}
else {
printf("%d, ", i);
}
i=i-2;
}
while(i>=-13);
i=0;
while(i<=9){
if (i==9){
printf("%d \n", i*i);
}
else{
printf("%d, ", i*i);
}
i++;
}
return 0;
}
@@ -0,0 +1,19 @@
#include <stdio.h>
int main(void){
int c_round;
float c_exact;
int f=0;
int max_f = 300;
int steps = 20;
printf("Fahrenheit \t Celsius(gerundet) \t Celsius(exakt) \n");
while(f <= max_f){
c_exact = (5.0/9.0) * (f - 32.0);
printf("%i \t\t %i \t\t\t %f \n", f, (int)c_exact, c_exact);
f+=steps;
}
return 0;
}
@@ -0,0 +1,25 @@
/* typengroesse.c
*
* Bestimmung der Groesse der einfachen typen mit sizeof
*/
#include <stdio.h>
int main() {
char c = 127;
unsigned char uc = 255;
printf("\n");
printf("char: \t\t%2d\n", (int) sizeof c);
printf("short: \t\t%2d\n", (int) sizeof (short));
printf("int: \t\t%2d\n", (int) sizeof (int));
printf("long: \t\t%2d\n", (int) sizeof (long));
printf("long long: \t%2d\n", (int) sizeof (long long));
printf("float: \t\t%2d\n", (int) sizeof (float));
printf("double: \t%2d\n", (int) sizeof (double));
printf("long double: \t%2d\n", (int) sizeof (long double));
printf("_Bool: \t\t%2d\n", (int) sizeof (_Bool));
printf("\n");
return 0;
}
Binary file not shown.
@@ -0,0 +1,27 @@
#include <stdio.h>
int main(void){
int i = 12;
while(i>=0){
printf("%i, ",i);
i-=2;
}
printf("\n");
i = -1;
while(i>=-13){
printf("%i, ", i);
i-=2;
}
printf("\n");
i = 0;
do{
printf("%i, ", i*i);
i++;
} while(i<=9);
}