Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epune daniel #244

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
61 changes: 61 additions & 0 deletions QUESTION FOUR
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <stdio.h>
#include <stdlib.h>

int array1[5]={1,2,3,4,5};
int array2[5]={5,7,8,9,3};
int array3[5];
int i;
void addarrays(array1,array2);
main()
{
for (i = 0; i < 5; i++)
printf( "\narray1 [%d] = %d \tarray2 [%d] = %d ", i,
array1 [i], i, array2 [i] );

addarrays(array1,array2);

return 0;
}
void addarrays(array1,array2)
{
for (i = 0; i < 5; i++)
array3[i]=(array1 [i]+ array2[i]);

printf("\n\nARRAY3 sums up 2 and 1");
printf("\n.......................\n");

for (i = 0; i < 5; i++)
printf( "\narray3 arrays is = %d ", array3[i] );

return 0;
}

part two

#include <stdio.h>
#include <stdlib.h>

int array1[5]={1,2,3,4,5};
int array2[5]={5,7,8,9,3};
int array3[5];
int i;
void *addarrays(array1,array2);
main()
{
for (i = 0; i < 5; i++)
printf( "\narray1 [%d] = %d \tarray2 [%d] = %d ", i,
array1 [i], i, array2 [i] );

int *array3=addarrays(array1,array2);

for (i = 0; i < 5; i++)
printf( "\narray3 arrays is = %d ", array3[i] );
return 0;
}
void *addarrays(array1,array2)
{
int *addarrays(array1,array2)
array3[i]=(array1 [i]+ array2[i])

return 0;
}
15 changes: 15 additions & 0 deletions QUESTION ONE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>
/* correction to the bugs in question one*/
int x=1;
/* its an error to use : when terminating a variable use ;*/

int main()
{
if (x==1)/* an if condition is not terminated */
printf("x is equal to 1\n");
/*otherwise is not a C keyword instead use else */
else
printf("x does not equal \n1");

return 0;
}
39 changes: 39 additions & 0 deletions QUESTION THREE
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

// declarration for an array named data

long data[50];

// this assigning a float value to an array

float data[49]=123.456;

/*when a for loop is run then x values will range from 0 to 99*/
int x
for(x=0;x<100;x++)
printf("%d\n",x);

//for is aloop hence we expect a range of values
int ctr;
for( ctr=2;ctr<10;ctr+=3)
printf("%d\n", ctr);
the values printed here will be 2,5,8

// symantics of a while loop

#include <stdio.h>

int main()
{
int count=1;
while(count<=100)
{
printf("%d\n",count);
count+=3;
}
return 0;
}

the for (statement) should not be terminated
i.e for(counter=1;counter< MAXVALUES;counter++)
printf("\n counter=%d", counter);

25 changes: 25 additions & 0 deletions QUESTION TWO
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

/*this is a header file do_it with returning a float
with characters as list of parameters*/
float do_it(char1,char2,char3)

/*this function return any value*/
void print_a_number (int x)


#include<stdio.h>
// alway terminate when u call a function
void print_msg (void);
main()
{
//the braces should be empty hence should not take any aguments
print_msg();
return 0;
}
//the header function should be identical at any point when called
void print_msg(void)
{
puts("this is the message to print");

return 0;
}
4 changes: 4 additions & 0 deletions STUDENT DETAILS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EPUNE DANIEL
17/U/19796/PS
217022078
BELE