diff --git a/QUESTION FOUR b/QUESTION FOUR new file mode 100644 index 00000000..763ead82 --- /dev/null +++ b/QUESTION FOUR @@ -0,0 +1,33 @@ +#include +void addarrays(int array1[], int array2[], int destination_array[], int SIZE) +{ + for(int i=0;i +int *addarrays(int arraya[],int arrayb[], int SIZE); +main(){ +int arraya[] = {2,3,5,9,10}; +printf("arraya[2,3,5,9,10]\n"); +int arrayb[] = {10,23,25,17,16}; + printf("arrayb[10,23,25,17,16]\n"); + printf("arrayc "); +int *arrayc = addarrays(arraya, arrayb, 5); +int i; +for( i=0;i<5;i++) { +printf("%d,", arrayc[i]); +} +} + +int *addarrays(int arraya[], int arrayb[], int length){ +int *destination_array = malloc(length * sizeof(int)); +int i; +for( i=0;i +#include +main() +{ + int x = 1; + + if(x==1) + { + printf("x equals 1"); + } + else + { + printf("x does not equal 1"); + } + return 0; +} + diff --git a/QUESTION THREE b/QUESTION THREE new file mode 100644 index 00000000..057921b5 --- /dev/null +++ b/QUESTION THREE @@ -0,0 +1,24 @@ +/*declaration of an array that will hold type long values*/ +long people[50]; + +/* A statement that assigns a value of 123.456 to the 50th element in the array*/ +long people[49]=123456; + +/* what is the value of x whenthe following statement is complete*/ +for(x=0;x<100,x++) /* The final value of x is 100 */ + +/* What is the value of ctr when the following statment is complete */ +for(ctr=2;ctr<10;ctr+=3) /* The final value of ctr is 11 */ + + /* A while statement to count from 1 to 100 in intervals of 3s */ + int x=1; + while(x<=100) + { + printf("%d",x); + x+=3; + } + + /* What is wrong with the folowing code fragment(MAXVALUES is the problem!)*/ + for(counter=1;counter