From 0deedd3fec37dfeab70a3b38759e553728f2d81e Mon Sep 17 00:00:00 2001 From: WalterHAKIZA Date: Thu, 12 Apr 2018 01:52:19 -0700 Subject: [PATCH 1/4] question 1 --- quest1.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 quest1.txt diff --git a/quest1.txt b/quest1.txt new file mode 100644 index 00000000..180950c2 --- /dev/null +++ b/quest1.txt @@ -0,0 +1,11 @@ +//program without errors + #include + int x= 2; + main() + { + if( x == 1) + printf(" x equals 1" ); + else + printf(" x does not equal 1"); + return 0; + } From df7312b2657170ccd41accdf684b6a3cf90aeb0a Mon Sep 17 00:00:00 2001 From: WalterHAKIZA Date: Thu, 12 Apr 2018 01:52:44 -0700 Subject: [PATCH 2/4] question2 --- quest2.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 quest2.txt diff --git a/quest2.txt b/quest2.txt new file mode 100644 index 00000000..86a42ba1 --- /dev/null +++ b/quest2.txt @@ -0,0 +1,32 @@ +//part a + #include + float do_it(char x,char y,char z); + int main(){ + + return 0; + } + + + +/* part b*/ +#include +void print_a_number(int a); +int main (){ + +return 0; +} + + +/* part c*/ +#include + void print_msg( void ); + main(){ + print_msg("This is a message to print");// the function here is not known + + return 0; + } + void print_msq( void ) + { + puts("This is a message to print"); + return 0; //a void function returns nothing + } From fa3bb5b171e6459e30b8e55b321ccf4e83357d60 Mon Sep 17 00:00:00 2001 From: WalterHAKIZA Date: Thu, 12 Apr 2018 01:53:08 -0700 Subject: [PATCH 3/4] question 3 --- quest3.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 quest3.txt diff --git a/quest3.txt b/quest3.txt new file mode 100644 index 00000000..62d17808 --- /dev/null +++ b/quest3.txt @@ -0,0 +1,32 @@ +#include + + int main(){ + long array[50]; + + array[49]=123.456; + + return 0; + } + +// part b +x will be equal to 99 + +// part c +ctr will be 8 + +// part d +#include + + int main(){ + int x =1; + while(x<=100){ + printf("%d\n",x); + x+=3; + + } + return 0; + } + +// part + for (counter = 1; counter < MAXVALUES; counter++ ); // the termination of the for loop here means that the printf function is not going to be looped through. + printf("\nCounter = %d", counter); From ff0bcf8077854faaf1d87db1a9e493c81090f5ea Mon Sep 17 00:00:00 2001 From: WalterHAKIZA Date: Thu, 12 Apr 2018 01:53:34 -0700 Subject: [PATCH 4/4] question 4 --- quest4.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 quest4.txt diff --git a/quest4.txt b/quest4.txt new file mode 100644 index 00000000..a4e19ecc --- /dev/null +++ b/quest4.txt @@ -0,0 +1,33 @@ +#include + void addarrays(int [], int[], int*); + int main(){ + int counter; + + int a[] = {1,2,3}; + int b[] = {8,5,8}; + int size = (int)sizeof(b)/4; + int c[size]; +// for (counter = 1; counter < MAXVALUES; counter++ ) +// printf("\nCounter = %d", counter); + if ((int)sizeof(a)==(int)sizeof(b)){ + addarrays(a,b,c); + for (counter = 0; counter < size; counter++ ){ + + printf("\n %d", c[counter]); + } + + }else{ + printf("input array of same size"); + } + + + return 0; + } + + void addarrays(int a[], int b[], int* c){ + int i ,j; + for (i=0,j=0 ; i