From c08e574c6da079a0b6d93bb344c017806045ba8a Mon Sep 17 00:00:00 2001 From: simonemmanuel <38223027+simonemmanuel@users.noreply.github.com> Date: Thu, 12 Apr 2018 12:30:42 +0400 Subject: [PATCH 1/8] Create QUESTION 1 --- QUESTION 1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 QUESTION 1 diff --git a/QUESTION 1 b/QUESTION 1 new file mode 100644 index 00000000..1e9cf858 --- /dev/null +++ b/QUESTION 1 @@ -0,0 +1,16 @@ + /* a program with problems...*/ +#include +int x =1; /*Use of semicolon*/ +main() +{ + if(x==1) /*apply the double equal signs instead of one*/ + { + printf("x equals 1\n"); + } + else /* use else instead of otherwise*/ + { + printf(" x does not equal 1"); + } + return 0; +} + From 89dbee102784037447e5f336df5d4710d08b9f48 Mon Sep 17 00:00:00 2001 From: simonemmanuel <38223027+simonemmanuel@users.noreply.github.com> Date: Thu, 12 Apr 2018 12:33:21 +0400 Subject: [PATCH 2/8] Create QUESTION 2 --- QUESTION 2 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 QUESTION 2 diff --git a/QUESTION 2 b/QUESTION 2 new file mode 100644 index 00000000..ea3b7442 --- /dev/null +++ b/QUESTION 2 @@ -0,0 +1,22 @@ + a) + +float do_it(char 1, char 2, char 3) /*headers don't terminate*/ + + b) + +void print_a_number(int Y) + + c) + + +#include +void print_msg(void); /* the print_msg() function name must be the same through out.*/ +main(){ +print_msg(); /* the print_msg() is not suppose to take any arguments. */ +return 0; +} +void print_msg(void) +{ + puts("This is a message to print"); + return 0; +} From 9f6ed14d9995dbd39433009391a35e47881a5c09 Mon Sep 17 00:00:00 2001 From: simonemmanuel <38223027+simonemmanuel@users.noreply.github.com> Date: Thu, 12 Apr 2018 12:37:01 +0400 Subject: [PATCH 3/8] Create QUESTION 3 --- QUESTION 3 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 QUESTION 3 diff --git a/QUESTION 3 b/QUESTION 3 new file mode 100644 index 00000000..863fc2e6 --- /dev/null +++ b/QUESTION 3 @@ -0,0 +1,31 @@ + a) + +long array [50]; + + b) + +array [49] = 123.456; + c) + +x is equal to 100. + d) + +The value of ctr will be 11. + e) + +#include +counter = 1; +main() +{ + while(counter <= 100) + { + printf("%d\n", counter ); + counter += 3; + } + return 0; +} + + f) +for (counter =1; counter < MAXVALUES; counter++) /* We don't terminate on for loop statement*/ + printf("\nCounter = %d", counter); + From c1587dfe83ed8a7ef25c4ff79e15963fd72dba4f Mon Sep 17 00:00:00 2001 From: simonemmanuel <38223027+simonemmanuel@users.noreply.github.com> Date: Thu, 12 Apr 2018 12:41:23 +0400 Subject: [PATCH 4/8] Create QUESTION 4 --- QUESTION 4 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 QUESTION 4 diff --git a/QUESTION 4 b/QUESTION 4 new file mode 100644 index 00000000..7a9737d4 --- /dev/null +++ b/QUESTION 4 @@ -0,0 +1,40 @@ + 4a) + +#include +#include +int j, n; +int main() +{ +int *addarrays(int n, int x[], int y[], int z[]) + int i; + for (i=0; i +int *addarrays(int array1[], int array2[], int SIZE); +main() +{ +int array1[] = {2,5,3,22,6}; +int array2[] = {13,143,11,10,121}; +int *array3 = addarrays(array1, array2, 5); +for(int i=0;i<5;i++) + { + printf("%d ", array3[i]); + } +} +int *addarrays(int array1[], int array2[], int length) +{ +int *destination_array = malloc(length * sizeof(int)); +for(int i=0;i Date: Thu, 12 Apr 2018 12:45:43 +0400 Subject: [PATCH 5/8] Create QUESTION ONE --- QUESTION ONE | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 QUESTION ONE diff --git a/QUESTION ONE b/QUESTION ONE new file mode 100644 index 00000000..ac0db2db --- /dev/null +++ b/QUESTION ONE @@ -0,0 +1,16 @@ + /* a program with problems...*/ +#include + int x =1; /*Use of semicolon*/ +main() +{ + if(x==1) /*use of assignment operator instead of relational operation .*/ + { + printf("x equals 1\n"); + } + else /* use else instead of otherwise*/ + { + printf(" x does not equal 1"); + } + return 0; +} + From 956a890043712d475b9f72bc1db3df6c74f9c5be Mon Sep 17 00:00:00 2001 From: simonemmanuel <38223027+simonemmanuel@users.noreply.github.com> Date: Thu, 12 Apr 2018 12:47:06 +0400 Subject: [PATCH 6/8] Create QUESTION TWO --- QUESTION TWO | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 QUESTION TWO diff --git a/QUESTION TWO b/QUESTION TWO new file mode 100644 index 00000000..8de3f070 --- /dev/null +++ b/QUESTION TWO @@ -0,0 +1,17 @@ +A) float do_it(char a, char b, char c) /*headers don't terminate*/ + + +B) void print_a_number(int x) + + +C) #include +void print_msg(void); /* the print_msg() function name must be the same through out.*/ +main(){ +print_msg(); /* the print_msg() is not suppose to take any arguments. */ +return 0; +} +void print_msg(void) +{ + puts("This is a message to print"); + return 0; +} From b13adad3b14a6a639bf029ec4a469ce27fe51df9 Mon Sep 17 00:00:00 2001 From: simonemmanuel <38223027+simonemmanuel@users.noreply.github.com> Date: Thu, 12 Apr 2018 12:48:50 +0400 Subject: [PATCH 7/8] Create QUESTION THREE --- QUESTION THREE | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 QUESTION THREE diff --git a/QUESTION THREE b/QUESTION THREE new file mode 100644 index 00000000..6bd8ea00 --- /dev/null +++ b/QUESTION THREE @@ -0,0 +1,24 @@ +A) long array [50]; + +B) array [49] = 123.456; + +C) x = 100. + +D) ctr = 11. + +E) #include +counter = 1; +main() +{ + while(counter <= 100) + { + printf("%d\n", counter ); + counter += 3; + } + return 0; +} + + + F) for (counter =1; counter < MAXVALUES; counter++) /* We don't terminate on for loop statement*/ + printf("\nCounter = %d", counter); + From 712181187d77dfd89ba410e29255c6bb3b26115d Mon Sep 17 00:00:00 2001 From: simonemmanuel <38223027+simonemmanuel@users.noreply.github.com> Date: Thu, 12 Apr 2018 12:50:48 +0400 Subject: [PATCH 8/8] Create QUESTION FOUR --- QUESTION FOUR | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 QUESTION FOUR diff --git a/QUESTION FOUR b/QUESTION FOUR new file mode 100644 index 00000000..5d213be6 --- /dev/null +++ b/QUESTION FOUR @@ -0,0 +1,42 @@ + + +A) + +#include +#include +int j, n; +int main(){ + + +int *addarrays(int n, int x[], int y[], int z[]) + int i; + for (i=0; i +int *addarrays(int array1[], int array2[], int SIZE); +main(){ +int array1[] = {3,5,4,7,9}; +int array2[] = {3,6,8,2,45}; +int *array3 = addarrays(array1, array2, 5); +for(int i=0;i<5;i++) { +printf("%d ", array3[i]); +} +} +int *addarrays(int array1[], int array2[], int length){ +int *destination_array = malloc(length * sizeof(int)); +for(int i=0;i