From a7ebbbe9a08fb855cc1551ebf94f69e8db97c90f Mon Sep 17 00:00:00 2001 From: BAYEGA <38314712+BAYEGA@users.noreply.github.com> Date: Thu, 12 Apr 2018 02:02:51 -0700 Subject: [PATCH 1/4] question 1 --- question1.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 question1.txt diff --git a/question1.txt b/question1.txt new file mode 100644 index 00000000..180950c2 --- /dev/null +++ b/question1.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 9e1b8a7ff586c12d9633b99dbd328adcfdabeba3 Mon Sep 17 00:00:00 2001 From: BAYEGA <38314712+BAYEGA@users.noreply.github.com> Date: Thu, 12 Apr 2018 02:03:18 -0700 Subject: [PATCH 2/4] question2 --- question2.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 question2.txt diff --git a/question2.txt b/question2.txt new file mode 100644 index 00000000..86a42ba1 --- /dev/null +++ b/question2.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 a0eb0fe33ca033be2d75e62a53a12c2a2e868776 Mon Sep 17 00:00:00 2001 From: BAYEGA <38314712+BAYEGA@users.noreply.github.com> Date: Thu, 12 Apr 2018 02:03:44 -0700 Subject: [PATCH 3/4] question 3 --- question3.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 question3.txt diff --git a/question3.txt b/question3.txt new file mode 100644 index 00000000..62d17808 --- /dev/null +++ b/question3.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 535d22266acf05f876f470c67bbd8c092a71aed5 Mon Sep 17 00:00:00 2001 From: BAYEGA <38314712+BAYEGA@users.noreply.github.com> Date: Thu, 12 Apr 2018 02:04:13 -0700 Subject: [PATCH 4/4] question 4 --- question4.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 question4.txt diff --git a/question4.txt b/question4.txt new file mode 100644 index 00000000..8ad59b52 --- /dev/null +++ b/question4.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; // i divided by 4 because the size of function gives the total number of bytes in the array + 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 ; + for (i=0; i