upd course
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdalign.h>
|
||||||
|
|
||||||
|
// Logical Operators //
|
||||||
|
// If we got 90 or higher
|
||||||
|
// AND
|
||||||
|
// If we have less than 50 bucks
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
int money;
|
||||||
|
int grade;
|
||||||
|
|
||||||
|
printf("Enter money and grade: \n");
|
||||||
|
scanf("%d%d", &money, &grade);
|
||||||
|
|
||||||
|
if (money < 50 && grade > 90)
|
||||||
|
|
||||||
|
if (money < 50 || grade > 90)
|
||||||
|
|
||||||
|
if (!(grade > 80))
|
||||||
|
printf("Good Job! \n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
char operation;
|
||||||
|
float num1, num2;
|
||||||
|
|
||||||
|
printf("Welche Rechenoperation möchten sie durchführen? \n");
|
||||||
|
printf("+, -, /, * - Bitte geben Sie das Zeichen ein: \n");
|
||||||
|
|
||||||
|
scanf("%c", &operation);
|
||||||
|
|
||||||
|
printf("Bitte geben sich 2 Zahlen ein!\n");
|
||||||
|
printf("num 1: ");
|
||||||
|
scanf("%f", &num1);
|
||||||
|
printf("num 2: ");
|
||||||
|
scanf("%f", &num2);
|
||||||
|
|
||||||
|
switch (operation)
|
||||||
|
{
|
||||||
|
case '+':
|
||||||
|
printf("%.2f %c %.2f = %.2f \n", num1, operation, num2, num1 + num2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-':
|
||||||
|
printf("%.2f %c %.2f = %.2f \n", num1, operation, num2, num1 - num2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '*':
|
||||||
|
printf("%.2f %c %.2f = %.2f \n", num1, operation, num2, num1 * num2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '/':
|
||||||
|
printf("%.2f %c %.2f = %.2f \n", num1, operation, num2, num1 / num2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("ERROR - falsche Eingabe! \n");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
//Made by Vlad. Budnitski.
|
||||||
|
//AlphaTech - Programming Course.
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
char grade; // not an int, yes? :)
|
||||||
|
printf("Enter your grade (A-F) : ");
|
||||||
|
scanf("%c", &grade);
|
||||||
|
switch (grade) // Specifying Variable
|
||||||
|
{
|
||||||
|
case 'A': // grade == 'A'
|
||||||
|
printf("Grade between 90-100 \n");
|
||||||
|
break;
|
||||||
|
case 'B': // grade == 'B'
|
||||||
|
printf("Grade between 80-89 \n");
|
||||||
|
break;
|
||||||
|
case 'C': // grade == 'C'
|
||||||
|
printf("Grade between 70-79 \n");
|
||||||
|
break;
|
||||||
|
case 'D': // grade == 'D'
|
||||||
|
printf("Grade between 60-69 \n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("ERROR.. Try Again! \n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
//Made by Vlad. Budnitski.
|
||||||
|
//AlphaTech - Programming Course.
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int num1, num2;
|
||||||
|
char mathOperation;
|
||||||
|
printf("Enter what math operation you would like to use : ('+', '-', ..): ");
|
||||||
|
scanf("%c", &mathOperation);
|
||||||
|
printf("Enter num1: ");
|
||||||
|
scanf("%d", &num1);
|
||||||
|
printf("Enter num2: ");
|
||||||
|
scanf("%d", &num2);
|
||||||
|
|
||||||
|
switch (mathOperation)
|
||||||
|
{
|
||||||
|
case '+':
|
||||||
|
printf("%d %c %d = %d\n", num1, mathOperation, num2, num1 + num2);
|
||||||
|
break;
|
||||||
|
case '-':
|
||||||
|
printf("%d %c %d = %d\n", num1, mathOperation, num2, num1 - num2);
|
||||||
|
break;
|
||||||
|
case '*':
|
||||||
|
printf("%d %c %d = %d\n", num1, mathOperation, num2, num1 * num2);
|
||||||
|
break;
|
||||||
|
case '/':
|
||||||
|
if (num2 == 0)
|
||||||
|
printf("You cannot divide by 0! \n");
|
||||||
|
else
|
||||||
|
printf("%d %c %d = %d\n", num1, mathOperation, num2, num1 / num2);
|
||||||
|
break;
|
||||||
|
case '%':
|
||||||
|
if (num2 == 0)
|
||||||
|
printf("You cannot divide by 0! \n");
|
||||||
|
else
|
||||||
|
printf("%d %c %d = %d\n", num1, mathOperation, num2, num1 % num2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("Wrong mathematical operation.. Try again. \n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
char grade;
|
||||||
|
printf("Enter your grade (A-F): ");
|
||||||
|
scanf("%c", &grade);
|
||||||
|
|
||||||
|
if (grade == 'A')
|
||||||
|
printf("You have a score within a range of 90-100 point.\n");
|
||||||
|
|
||||||
|
else if (grade == 'B')
|
||||||
|
printf("You have a score within a range of 80-89 point.\n");
|
||||||
|
|
||||||
|
else if (grade == 'C')
|
||||||
|
printf("You have a score within a range of 70-79 point.\n");
|
||||||
|
|
||||||
|
else if (grade == 'D')
|
||||||
|
printf("You have a score within a range of 60-69 point.\n");
|
||||||
|
|
||||||
|
else if (grade == 'E')
|
||||||
|
printf("You have a score within a range of 50-59 point.\n");
|
||||||
|
|
||||||
|
else if (grade == 'F')
|
||||||
|
printf("You have a score within a range of 0-49 point.\n");
|
||||||
|
|
||||||
|
else
|
||||||
|
printf("Oh. Something went wrong.\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
char grade;
|
||||||
|
printf("Enter your grade (A-F): ");
|
||||||
|
scanf("%c", &grade);
|
||||||
|
|
||||||
|
switch (grade)
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
printf("Grade between 90-100\n");
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
printf("Grade between 80-89\n");
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
printf("Grade between 70-79\n");
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
printf("Grade between 60-69\n");
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
printf("Grade between 50-59\n");
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
printf("Grade between 0-49\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("ERROR.. Try Again! \n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int val1, val2, val3, auswertung;
|
||||||
|
printf("EQUAL or NOT EQUAL\n");
|
||||||
|
|
||||||
|
printf("Value 1: ");
|
||||||
|
scanf("%i", &val1);
|
||||||
|
|
||||||
|
printf("Value 2: ");
|
||||||
|
scanf("%i", &val2);
|
||||||
|
|
||||||
|
auswertung = (val1 == val2) ? 1 : 2;
|
||||||
|
// printf("Auswertung: %i\n", auswertung);
|
||||||
|
|
||||||
|
switch (auswertung)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
printf("%i and %i are equal\n", val1, val2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
printf("%i and %i are not equal\n", val1, val2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* Frage 1: Write a program that reads from the user 2 values
|
||||||
|
of an "integer" type. The program should print "EQUAL" if both
|
||||||
|
the values are equal. Otherwise, the program should print "NOT EQUAL". */
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int val1, val2, val3, auswertung;
|
||||||
|
printf("EQUAL or NOT EQUAL\n");
|
||||||
|
|
||||||
|
printf("Value 1: ");
|
||||||
|
scanf("%i", &val1);
|
||||||
|
|
||||||
|
printf("Value 2: ");
|
||||||
|
scanf("%i", &val2);
|
||||||
|
|
||||||
|
printf("Value 3: ");
|
||||||
|
scanf("%i", &val3);
|
||||||
|
auswertung = (val1 == val2 && val2 == val3) ? 1 : 2;
|
||||||
|
printf("Auswertung: %i\n", auswertung);
|
||||||
|
|
||||||
|
switch (auswertung)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
printf("%i and %i and %i are equal\n", val1, val2, val3);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
printf("%i and %i and %i are not equal\n", val1, val2, val3);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
|
||||||
|
int first, second, third;
|
||||||
|
|
||||||
|
printf("Geben Sie eine dreistellige Zahl ein: \n");
|
||||||
|
scanf("%i", &value);
|
||||||
|
|
||||||
|
first = value / 100;
|
||||||
|
printf("first: %i\n", first);
|
||||||
|
|
||||||
|
second = (value - first * 100) / 10;
|
||||||
|
printf("second: %i\n", second);
|
||||||
|
|
||||||
|
third = (value - first * 100) - second * 10;
|
||||||
|
printf("third: %i\n", third);
|
||||||
|
|
||||||
|
if (first < second && second < third)
|
||||||
|
{
|
||||||
|
printf("ASCENDING\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("NOT ASCENDING\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,30 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int num;
|
||||||
|
|
||||||
|
printf("Please enter a number: \n");
|
||||||
|
|
||||||
|
scanf("%i", &num);
|
||||||
|
|
||||||
|
if (num < 0)
|
||||||
|
{
|
||||||
|
printf("-1");
|
||||||
|
}
|
||||||
|
else if (num > 0)
|
||||||
|
{
|
||||||
|
printf("1");
|
||||||
|
}
|
||||||
|
else if (num == 0)
|
||||||
|
{
|
||||||
|
printf("0");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user