Skip to content
Open

DONE #249

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions QUESTION 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*PROGRAM WITHOUT ERRORS */
#include<stdio.h>

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;
}
43 changes: 43 additions & 0 deletions QUESTION 2
Original file line number Diff line number Diff line change
@@ -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<stdio.h>
#include<stdlib.h>
#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<stdio.h>
#include<stdlib.h>
#include"print_a_number.h"
void print_a_number(int a)//DEFINING A FUNCTION
{
statements---------
}


/*QUESTION TWO PART 3*/
#include<stdio.h>
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;
}

26 changes: 26 additions & 0 deletions QUESTION 3
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <stdlib.h>

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);

67 changes: 67 additions & 0 deletions QUESTION 4
Original file line number Diff line number Diff line change
@@ -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<p;i++)
{
z[i]=x[i]+y[i];
}
}

//*PART 2*//

#include <stdio.h>
#include <stdlib.h>
int m,p;
int *addarrays(int N, int x[],int y[],int z[])
{
for (m=0;m<N;m++)
{
z[m]=x[m]+y[m];
}
return z;
}

int main()
{
int p, x[p], y[p], z[p], *address;
printf("ENTER ARRAY SIZE\n");
scanf("%d",&p);
printf("ENTER ELEMENTS OF ARRAY x[]");
for (m=0;m<p;m++)
{
printf("ENTER ELEMENTS OF x[m]\n",m);
scanf("%d",x);
}
printf("ENTER ELEMENTS OF ARRAY y[]");
for (m=0;m<p;m++)
{
printf("ENTER ELEMENTS OF y[m]\n",m);
scanf("%d",y);
}
address=addarrays(p, x, y, z);
printf("THE ADDRESS OF z[] IS %d\n",address);
printf("ELEMENTS OF ARRAY x[] array:\n");
for(m=0;m<p;m++)
{
printf("%d",x[m]);
}
printf("ELEMENTS OF ARRAY y[] array:\n");
for(m=0;m<p;m++)
{
printf("%d",y[m]);

printf("ELEMENTS OF ARRAY z[] array:\n");
for(m=0;m<p;m++)
{
printf("%d",z[m]);
}



return 0;
}