diff --git a/QUESTION 1 b/QUESTION 1 new file mode 100644 index 00000000..82378694 --- /dev/null +++ b/QUESTION 1 @@ -0,0 +1,13 @@ +/*PROGRAM WITHOUT ERRORS */ +#include + +int x= 1;/* WE SHOULD TERMINATE USING SEMI COLONS INSTEAD OF FULL COLONS*/ +int main() + + { +if( x ==1)/* WE SHOULD USE DOUBLE EQUAL SIGNS INSTEAD OF SINGLE EQUAL SIGNS*/ +printf(" x equals 1" ); +else /*HERE WE USE "IF" ACCOMPANED WITH "ELSE" BUT NOT OTHERWISE*/ +printf(" x does not equal 1"); +return 0; + } diff --git a/QUESTION 2 b/QUESTION 2 new file mode 100644 index 00000000..e8223e54 --- /dev/null +++ b/QUESTION 2 @@ -0,0 +1,43 @@ +/*QUESTION 2 PART 1*/ +//do_it.h DECLARATION +float do_it(char x, char y, char z); + + +do_it.c +#include +#include +#include"do_it.h" +float do_it(char x, char y,char z) //DEFINING A FUNCTION +{ +statements-------- +} + +/*QUESTION 2 PART 2*/ +//print_a_number.h declaration +void print_a_number(int a); + + +print_a_number.c +#include +#include +#include"print_a_number.h" +void print_a_number(int a)//DEFINING A FUNCTION +{ +statements--------- +} + + +/*QUESTION TWO PART 3*/ +#include +voidprint_msg( void ); +main()//FOR "MAIN" TO RETURN 0 IT SHOULD BE DECLARED AS "int main"" +{ +print_msg("This is a message to print");/*THIS SHOULD NOT BE WITH ANY ARGUMENTS IN THE BRACKETS*/ +return 0; + } +voidprint_msq( void )//THE WORD msg IS WRONGLY SPELLED + { +puts("This is a message to print"); +return 0; + } + diff --git a/QUESTION 3 b/QUESTION 3 new file mode 100644 index 00000000..a263d413 --- /dev/null +++ b/QUESTION 3 @@ -0,0 +1,26 @@ +//*QUESTION THREE PART 1*// +long double r[50]; // r IS THE ARRAY NAME +//*PART 2*// +r[49]=123.456; // ASSIGNING THE VALUE TO THE 50TH ELEMENT IN THIS ARRAY +//*PART 3*// +X IS EQUAL TO 100. +ctr value IS EQUAL TO 11. + +#include +#include + +int main() +{ +int x=1; +while(x<=100) +{ +printf("%d\n",x); +x+=3; +} +return 0; +} + +//*PART 4*// +for (counter = 1; counter < MAXVALUES; counter++ );/* "FOR" STATEMENT IS NOT TERMINATED WITH SEMI COLON BECAUSE IT IS A FUNCTION*/ +printf("\nCounter = %d", counter); + diff --git a/QUESTION 4 b/QUESTION 4 new file mode 100644 index 00000000..d064bab7 --- /dev/null +++ b/QUESTION 4 @@ -0,0 +1,67 @@ +//*QUESTION FOUR PART 1*// +void addarrays (int p, int x[], int y[], int z[])//*THIS IS A FUNCTION DIFFINITION AND IT TAKES ON4 ARGUEMENTS*// +{ + int i; + for (i=0;i +#include +int m,p; +int *addarrays(int N, int x[],int y[],int z[]) +{ + for (m=0;m