Update to 2-1

This commit is contained in:
caskd 2019-11-01 12:51:56 +01:00
parent a300e1cc32
commit ed3ea680f4
No known key found for this signature in database
GPG Key ID: 79DB21404E300A27
2 changed files with 20 additions and 2 deletions

View File

@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.0)
project(learningc LANGUAGES C)
set(CHAPTER 1)
set(EXERCISE 24)
set(CHAPTER 2)
set(EXERCISE 2)
add_executable(learningc chapters/${CHAPTER}/exercises/${EXERCISE}.c)

18
chapters/2/exercises/1.c Normal file
View File

@ -0,0 +1,18 @@
#include <limits.h>
#include <stdio.h>
int main() {
printf("Char range is:\n");
printf("\tSigned: %i to %i\n", CHAR_MIN, CHAR_MAX);
printf("\tUnsigned: %i to %i\n", 0, UCHAR_MAX);
printf("Short range is:\n");
printf("\tSigned: %i to %i\n", SHRT_MIN, SHRT_MAX);
printf("\tUnsigned: %i to %i\n", 0, USHRT_MAX);
printf("Int range is:\n");
printf("\tSigned: %i to %i\n", INT_MIN, INT_MAX);
printf("\tUnsigned: %i to %i\n", 0, UINT_MAX);
printf("Long range is:\n");
printf("\tSigned: %li to %li\n", LONG_MIN, LONG_MAX);
printf("\tUnsigned: %i to %lu\n", 0, ULONG_MAX);
return 0;
}