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

TWINE DAVIS 17/U/1837 #256

Open
wants to merge 4 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
7 changes: 7 additions & 0 deletions Question Four a.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
int final_array[] = {};
void addarrays(int array1[], int array2[], int array3[], int n) {
int i = 0;
for (i = 0; i < n; i++) {
array3[i] = array1[i] + array2[i];
}
}
50 changes: 50 additions & 0 deletions Question Four b.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <stdio.h>
#include <stdlib.h>

int array3[] = {};
int *addarrays(int array1[], int array2[], int n);

int main(void) {
int i,n;
printf("Enter the size of the arrays: \n");
scanf("%d",&n);
int array_one[n], array_two[n];

printf("Enter the first array: \n");

for ( i = 0; i < n; i++) {
scanf("%d", &array_one[i]);
}

printf("Enter the second array: \n");

for ( i = 0; i < n; i++) {
scanf("%d", &array_two[i]);
}

int *p;
p = addarrays(array_one, array_two, n);
printf("array one: ");
for (i=0; i < n; i++){
printf("%d,", array_one[i]);
}
printf("\narray two: ");
for (i=0; i < n; i++){
printf("%d,", array_two[i]);
}
printf("\narray3: ");
for (i=0; i < n; i++){
printf("%d,", p[i]);
}
return 0;
}

int *addarrays(int array1[], int array2[], int n) {
int i = 0;
for (i = 0; i < n; i++) {
array3[i] = array1[i] + array2[i];
}
int *t;
t = array3;
return t;
}
15 changes: 15 additions & 0 deletions Question One.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* a program with a fixed bug... */
#include <stdio.h>
int x = 1;
main()
{
if (x == 1){
printf("x equals 1");
}
else {
printf("x does not equal to 1");}
return 0;

}


31 changes: 31 additions & 0 deletions Question Three.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//Question 3 (a)
long ellarian[50];

//Question 3 (b)
ellarian[49] = 123.456;

//question 3 (c)
for (x = 0); x < 100; x++)
//value of x when the statement is complete is 100

//Question 3 (d)
for(ctr = 2; ctr < 10; ctr += 3)
//value of ctr when the statement is complete is 11

//Question 3 (e)
//while statement to count from 1 to 100 by 3s
#include <stdio.h>
int main(){
int i;
i = 1;

while(i<= 100)
{
printf("%d\n", i);
i += 3;
}
}
//Question 3 (f)
for (counter = 1; counter < MAXVALUES; counter++ );
printf("\nCounter = %d", counter);
//if the for loop is required to execute multiple times, then it wont be able because of the semicolon terminating the for loop
12 changes: 12 additions & 0 deletions Question Two .c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>
void print_msg( void );
main(){
print_msg("this is a message to print");
//the print_msg() function is not supposed to take any arguments but it is being called with a string argument
return 0;
}
void print_msq( void ) //the variable name is wrong,it is supposed to be print_msg instead of print_msq
{
puts("This is a message to print");
return 0;//the return 0 statement is not supposed to be there as nothing is meant to be returned
}
6 changes: 6 additions & 0 deletions do_it.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef DO_IT_H
#define DO_IT_H

float do_it(char p,char q,char z);

#endif
6 changes: 6 additions & 0 deletions print_a_number.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef PRINT_A_NUMBER_H__
#define PRINT_A_NUMBER_H__

void print_a_number(int y);

#endif