From 6293030b60ddd9d74f87a16e201ec23cc1ba3e96 Mon Sep 17 00:00:00 2001 From: AmbroseByamugisha <38299989+AmbroseByamugisha@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:32:31 +0300 Subject: [PATCH 1/5] Create question 1 --- question 1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 question 1 diff --git a/question 1 b/question 1 new file mode 100644 index 00000000..2d91ba05 --- /dev/null +++ b/question 1 @@ -0,0 +1,12 @@ +/* a program with problems ...*/ + +#include +int x = 1; +main() +{ + if(x == 1) + printf("x equals 1"); + else + printf("x does not equal 1"); + return 0; +} From f187f8af1fdb1548ea542a639ec981e7aa4fe2f9 Mon Sep 17 00:00:00 2001 From: AmbroseByamugisha <38299989+AmbroseByamugisha@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:48:42 +0300 Subject: [PATCH 2/5] Create number 2 --- number 2 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 number 2 diff --git a/number 2 b/number 2 new file mode 100644 index 00000000..db7e7176 --- /dev/null +++ b/number 2 @@ -0,0 +1,32 @@ +Number 2a solution; + + +float do_it(char A,char B,char C) + + +Number 2b solution; + + +void print_a_number (int a) + +number 2c sln; + +#include +void print_msg(void); + +main() +{ + print_msg(); + return 0; +} + +void print_msg(void) +{ + puts("This is a message to print"); + return 0; +} +/*the function name must be the same. it was wrong to put print_msq instead of print_msg*/ + +/* so the above program corrected prints 'This is a message to print'*/ +/*the funtion has arguments yet the declaration function had no arguments*/ + From eacc181c5a94c98f0534be3bb4f327d738db962a Mon Sep 17 00:00:00 2001 From: AmbroseByamugisha <38299989+AmbroseByamugisha@users.noreply.github.com> Date: Thu, 12 Apr 2018 11:52:06 +0300 Subject: [PATCH 3/5] Create number 3 --- number 3 | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 number 3 diff --git a/number 3 b/number 3 new file mode 100644 index 00000000..778163c4 --- /dev/null +++ b/number 3 @@ -0,0 +1,96 @@ +Number 3a solution; + +float a[50] + + +Number 3b solution; + +a[49]=123.456; + + + +number 3c sln; + +#include +#include + +int main() +{ + int x; + for(x=0;x<100;x++) + printf("%d\n",x); + return 0; +} + +/* 0<=x<=99*/ + + +number 3d sln; + +#include + +int main() +{ + int ctr; + + for(ctr=2;ctr<10;ctr+=3) + + printf("%d\n",ctr); + + return 0; +} +/*the value of ctr is 2,5 and 8*/ + + +number 3e sln; + +#include + +int main() +{ + int b=1; + +while (b<=100) +{ + printf("%d\n",b); + + b+=3; + + } + + return 0; +} +/*the values of x ranged 1<=x<=100*/ + + +number 3f sln; + + +#include +#include + +int main() +{ + int counter + + for(counter=1; counter Date: Thu, 12 Apr 2018 11:54:05 +0300 Subject: [PATCH 4/5] Create number 4 --- number 4 | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 number 4 diff --git a/number 4 b/number 4 new file mode 100644 index 00000000..bbeb891d --- /dev/null +++ b/number 4 @@ -0,0 +1,57 @@ +number 4a sln; + +void addarrays(int N, int x[],int y[],int z[]){ +int i; +for(i=0; i +#include +int N, i; +int *addarrays(int N,int x[],int y[],int z[]){ +int i; +for(i=0; i Date: Thu, 12 Apr 2018 11:55:38 +0300 Subject: [PATCH 5/5] Update question 1 --- question 1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/question 1 b/question 1 index 2d91ba05..582ad4ff 100644 --- a/question 1 +++ b/question 1 @@ -1,12 +1,13 @@ -/* a program with problems ...*/ - #include -int x = 1; +int x=1; main() { - if(x == 1) + if(x==1) printf("x equals 1"); else - printf("x does not equal 1"); + printf("x does not equal 1"); return 0; } + +/* the program initially had 'if (x=1)' which is simply an assignment operator not the equals sign*/ +/* the word 'otherwise' was used instead of 'else'*/