From 1f79ce0e3d2791534ad4b22e9e5ee6ba9ee5c74d Mon Sep 17 00:00:00 2001 From: danielepune <38095928+danielepune@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:53:04 +0300 Subject: [PATCH 1/5] Create QUESTION ONE --- QUESTION ONE | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 QUESTION ONE diff --git a/QUESTION ONE b/QUESTION ONE new file mode 100644 index 00000000..27ffad22 --- /dev/null +++ b/QUESTION ONE @@ -0,0 +1,15 @@ +#include +/* correction to the bugs in question one*/ +int x=1; +/* its an error to use : when terminating a variable use ;*/ + +int main() +{ + if (x==1)/* an if condition is not terminated */ + printf("x is equal to 1\n"); + /*otherwise is not a C keyword instead use else */ + else + printf("x does not equal \n1"); + +return 0; +} From a35dfdf6b520d28c0eb62784cc326765a3f26ab2 Mon Sep 17 00:00:00 2001 From: danielepune <38095928+danielepune@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:53:55 +0300 Subject: [PATCH 2/5] Create QUESTION TWO --- QUESTION TWO | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 QUESTION TWO diff --git a/QUESTION TWO b/QUESTION TWO new file mode 100644 index 00000000..aaa0165c --- /dev/null +++ b/QUESTION TWO @@ -0,0 +1,25 @@ + +/*this is a header file do_it with returning a float +with characters as list of parameters*/ +float do_it(char1,char2,char3) + +/*this function return any value*/ +void print_a_number (int x) + + +#include +// alway terminate when u call a function +void print_msg (void); +main() +{ + //the braces should be empty hence should not take any aguments +print_msg(); +return 0; +} + //the header function should be identical at any point when called +void print_msg(void) +{ + puts("this is the message to print"); + + return 0; +} From 81d44746bdaf71335d65539b8d2590c39c5384ff Mon Sep 17 00:00:00 2001 From: danielepune <38095928+danielepune@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:54:42 +0300 Subject: [PATCH 3/5] Create QUESTION THREE --- QUESTION THREE | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 QUESTION THREE diff --git a/QUESTION THREE b/QUESTION THREE new file mode 100644 index 00000000..6ce040cb --- /dev/null +++ b/QUESTION THREE @@ -0,0 +1,39 @@ + +// declarration for an array named data + +long data[50]; + +// this assigning a float value to an array + +float data[49]=123.456; + +/*when a for loop is run then x values will range from 0 to 99*/ +int x +for(x=0;x<100;x++) + printf("%d\n",x); + +//for is aloop hence we expect a range of values +int ctr; +for( ctr=2;ctr<10;ctr+=3) +printf("%d\n", ctr); +the values printed here will be 2,5,8 + +// symantics of a while loop + +#include + +int main() +{ + int count=1; + while(count<=100) + { + printf("%d\n",count); + count+=3; + } + return 0; +} + + the for (statement) should not be terminated + i.e for(counter=1;counter< MAXVALUES;counter++) + printf("\n counter=%d", counter); + From c9bc83fd7ff3772deb4f16f7e144b4683f269ff0 Mon Sep 17 00:00:00 2001 From: danielepune <38095928+danielepune@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:55:30 +0300 Subject: [PATCH 4/5] Create QUESTION FOUR --- QUESTION FOUR | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 QUESTION FOUR diff --git a/QUESTION FOUR b/QUESTION FOUR new file mode 100644 index 00000000..e937fe50 --- /dev/null +++ b/QUESTION FOUR @@ -0,0 +1,61 @@ +#include +#include + +int array1[5]={1,2,3,4,5}; +int array2[5]={5,7,8,9,3}; +int array3[5]; +int i; +void addarrays(array1,array2); +main() +{ + for (i = 0; i < 5; i++) + printf( "\narray1 [%d] = %d \tarray2 [%d] = %d ", i, + array1 [i], i, array2 [i] ); + +addarrays(array1,array2); + +return 0; +} +void addarrays(array1,array2) +{ + for (i = 0; i < 5; i++) + array3[i]=(array1 [i]+ array2[i]); + + printf("\n\nARRAY3 sums up 2 and 1"); + printf("\n.......................\n"); + + for (i = 0; i < 5; i++) + printf( "\narray3 arrays is = %d ", array3[i] ); + +return 0; +} + +part two + +#include +#include + +int array1[5]={1,2,3,4,5}; +int array2[5]={5,7,8,9,3}; +int array3[5]; +int i; +void *addarrays(array1,array2); +main() +{ + for (i = 0; i < 5; i++) + printf( "\narray1 [%d] = %d \tarray2 [%d] = %d ", i, + array1 [i], i, array2 [i] ); + +int *array3=addarrays(array1,array2); + + for (i = 0; i < 5; i++) + printf( "\narray3 arrays is = %d ", array3[i] ); +return 0; +} +void *addarrays(array1,array2) +{ + int *addarrays(array1,array2) + array3[i]=(array1 [i]+ array2[i]) + +return 0; +} From 59b31604f0e1a4b1e054ebcbc6ce6e28bc14ebdb Mon Sep 17 00:00:00 2001 From: danielepune <38095928+danielepune@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:56:34 +0300 Subject: [PATCH 5/5] 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..c7a489d4 --- /dev/null +++ b/STUDENT DETAILS @@ -0,0 +1,4 @@ +EPUNE DANIEL +17/U/19796/PS +217022078 +BELE