added weekly exercises of isp-ws25
This commit is contained in:
13
c/isp-ws25/weeklies/week01/w01ex01.c
Executable file
13
c/isp-ws25/weeklies/week01/w01ex01.c
Executable file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
Exercise 01:
|
||||
Get familiar with coding.
|
||||
Create a program that displays "Hello World!"
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello World!");
|
||||
return 0;
|
||||
}
|
||||
21
c/isp-ws25/weeklies/week01/w01ex02.c
Executable file
21
c/isp-ws25/weeklies/week01/w01ex02.c
Executable file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Exercise 02:
|
||||
Implemente a temperature converter.
|
||||
It should convert Fahrenheit to Celsius.
|
||||
The conversion may be done with this formula: C=(F-32)*5/9
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
float temp_f = 0;
|
||||
float temp_c = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Fahrenheit: ");
|
||||
scanf("%f", &temp_f);
|
||||
temp_c = (temp_f - 32)*5/9;
|
||||
printf("Celsius: %.2f\n", temp_c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
20
c/isp-ws25/weeklies/week01/w01ex03.c
Executable file
20
c/isp-ws25/weeklies/week01/w01ex03.c
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Exercise 03:
|
||||
Implement a ASCII-to-number converter.
|
||||
It should ask for a character, display it as a number, then the original character again.
|
||||
Insert enough spaces so that the character and number align.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
unsigned char input_char = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("%-17s", "Insert character: ");
|
||||
scanf("%c", &input_char);
|
||||
printf("%-17s %d\n", "Number: ", input_char);
|
||||
printf("%-17s %c\n", "ASCII Character: ", input_char);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user