From 1ad226193209fb5b13922bf75d69de01939b412c Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:40:57 +0300 Subject: [PATCH 01/13] Create Qtn 1 --- Qtn 1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Qtn 1 diff --git a/Qtn 1 b/Qtn 1 new file mode 100644 index 00000000..8c847eda --- /dev/null +++ b/Qtn 1 @@ -0,0 +1,15 @@ +#include +#include +int x=1;//it had a full colon instead of a semi-colon +main() +{ + if(x==1)// single equal sign(=)is not recognized as equal but instead double equal sigh(==) + { + printf("x equals 1"); + } + else // otherwise is not recognized by the compilers so we use else + { + printf("x does not equal 1"); + } + return 0; +} From b53822d9b45164863b1172e06685381d73ca4ffe Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:41:42 +0300 Subject: [PATCH 02/13] Create Qtn 2 p 1 --- Qtn 2 p 1 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Qtn 2 p 1 diff --git a/Qtn 2 p 1 b/Qtn 2 p 1 new file mode 100644 index 00000000..18c863a6 --- /dev/null +++ b/Qtn 2 p 1 @@ -0,0 +1,6 @@ +//do_it() +//the header for above function is as below +#ifndef DO_IT_H +#define DO_IT_H +float do_it(char a, char b, char c) +#endif // DO_IT_H From e99a85d22af0aa8a7bce091167d704140f165797 Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:42:20 +0300 Subject: [PATCH 03/13] Create Qtn 2 p2 --- Qtn 2 p2 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Qtn 2 p2 diff --git a/Qtn 2 p2 b/Qtn 2 p2 new file mode 100644 index 00000000..a436e1b3 --- /dev/null +++ b/Qtn 2 p2 @@ -0,0 +1,6 @@ +//print_a_number() +//the header for the above function is as below +#ifndef PRINT_A_NUMBER_H +#define PRINT_A_NUMBER_H +void print_a_number(int x) +#endif // PRINT_A_NUMBER_H From da69e95f0551645287af5e4954c663d303ee7585 Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:43:31 +0300 Subject: [PATCH 04/13] Create Qtn 2 p 3 --- Qtn 2 p 3 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Qtn 2 p 3 diff --git a/Qtn 2 p 3 b/Qtn 2 p 3 new file mode 100644 index 00000000..413f4c18 --- /dev/null +++ b/Qtn 2 p 3 @@ -0,0 +1,8 @@ + //the problems in the program of question 2 part 3 are below + -the function header was terminated and yet it + shouldn't be terminated + -the print_msg function shouldn't take any arguments + but the main function will call it with a string argument + -Another problem is that the function name in the function + declaration is print_msq() which is wrong because it sould + instead be print_msg() From fbbedf458e9ddcf162361f62e5adb99cf9985a43 Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:44:21 +0300 Subject: [PATCH 05/13] Create Qtn 3 p 1 --- Qtn 3 p 1 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Qtn 3 p 1 diff --git a/Qtn 3 p 1 b/Qtn 3 p 1 new file mode 100644 index 00000000..a1c14e2e --- /dev/null +++ b/Qtn 3 p 1 @@ -0,0 +1,3 @@ + //the declaration that will hold 50 type long values is as below + + long values[50]; From 55bcb366cd3067b6448bec9afe21d1f8dee8443b Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:45:09 +0300 Subject: [PATCH 06/13] Create Qtn 3 p 2 --- Qtn 3 p 2 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Qtn 3 p 2 diff --git a/Qtn 3 p 2 b/Qtn 3 p 2 new file mode 100644 index 00000000..2738cc0c --- /dev/null +++ b/Qtn 3 p 2 @@ -0,0 +1,3 @@ +// the statement that assigns the value 123.456 to the 50th element in the array + +long values[49] = 123.456; From 341350cb3efc6f535c11c5aefc2f1140865f6665 Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:45:53 +0300 Subject: [PATCH 07/13] Create Qtn 3 p 3 --- Qtn 3 p 3 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Qtn 3 p 3 diff --git a/Qtn 3 p 3 b/Qtn 3 p 3 new file mode 100644 index 00000000..885e33ac --- /dev/null +++ b/Qtn 3 p 3 @@ -0,0 +1,5 @@ +for (x=0;x<100;x++) + + //The value of x will be as below if the statement is complete + + x=100 From 4386850ad65b7afc7699d1d52bcd84523b1ea7e4 Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:46:27 +0300 Subject: [PATCH 08/13] Create Qtn 3 p 4 --- Qtn 3 p 4 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Qtn 3 p 4 diff --git a/Qtn 3 p 4 b/Qtn 3 p 4 new file mode 100644 index 00000000..aace6b62 --- /dev/null +++ b/Qtn 3 p 4 @@ -0,0 +1,3 @@ +for (ctr=2;ctr<10;ctr+=3) + // The value of ctr will be as below when the statement is complete + ctr=11 From 63dffcc85c6a6b14c8b099445b8cdadf5db5a374 Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:47:17 +0300 Subject: [PATCH 09/13] Create Qtn 3 p 5 --- Qtn 3 p 5 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Qtn 3 p 5 diff --git a/Qtn 3 p 5 b/Qtn 3 p 5 new file mode 100644 index 00000000..72b681b0 --- /dev/null +++ b/Qtn 3 p 5 @@ -0,0 +1,14 @@ +#include + +main() +{ + int count; + count=1; + while(count<=100) + { + printf("%d\n",count); + count+=3; + } + return 0; +} + From 2150980ae3c4b2b835ed393f7ce7752afcb23d94 Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:48:07 +0300 Subject: [PATCH 10/13] Create Qtn 3 p 6 --- Qtn 3 p 6 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Qtn 3 p 6 diff --git a/Qtn 3 p 6 b/Qtn 3 p 6 new file mode 100644 index 00000000..e2f879d1 --- /dev/null +++ b/Qtn 3 p 6 @@ -0,0 +1,5 @@ + for (counter = 1; counter < MAXVALUES; counter++ ); + printf("\nCounter = %d", counter); + //the problem with the above code fragment is + the semicolon at the end of the condition is the problem because a condition + shouldn't have a semicolon at the end From ed0093900621bcaef94584077f48c326f11d52e7 Mon Sep 17 00:00:00 2001 From: nichriston <38221091+nichriston@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:48:59 +0300 Subject: [PATCH 11/13] Create Qtn 4 p 1 --- Qtn 4 p 1 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Qtn 4 p 1 diff --git a/Qtn 4 p 1 b/Qtn 4 p 1 new file mode 100644 index 00000000..071e9bd5 --- /dev/null +++ b/Qtn 4 p 1 @@ -0,0 +1,8 @@ +#include +void addarrays(int array1[], int array2[], int destination_array[], int SIZE) +{ + for(int i=0;i Date: Thu, 12 Apr 2018 11:50:10 +0300 Subject: [PATCH 12/13] Create Qtn 4 p2 --- Qtn 4 p2 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Qtn 4 p2 diff --git a/Qtn 4 p2 b/Qtn 4 p2 new file mode 100644 index 00000000..e551b8fe --- /dev/null +++ b/Qtn 4 p2 @@ -0,0 +1,23 @@ + #include +int *addarrays(int arraya[],int arrayb[], int SIZE); +main(){ +int arraya[] = {2,3,5,9,10}; +printf("arraya[2,3,5,9,10]\n"); +int arrayb[] = {10,23,25,17,16}; + printf("arrayb[10,23,25,17,16]\n"); + printf("arrayc "); +int *arrayc = addarrays(arraya, arrayb, 5); +int i; +for( i=0;i<5;i++) { +printf("%d,", arrayc[i]); +} +} + +int *addarrays(int arraya[], int arrayb[], int length){ +int *destination_array = malloc(length * sizeof(int)); +int i; +for( i=0;i Date: Thu, 12 Apr 2018 11:51:44 +0300 Subject: [PATCH 13/13] Create Student details --- Student details | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Student details diff --git a/Student details b/Student details new file mode 100644 index 00000000..c6c65d84 --- /dev/null +++ b/Student details @@ -0,0 +1,4 @@ +Niwamanya Ton Chritopher +17U/1698 +BELE +217001732