Skip to content
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
13 changes: 13 additions & 0 deletions q1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>

int main()
{
int x = 1;
if( x == 1){
printf(" x equals 1" );
}
else {
printf(" x does not equal 1");
}
return 0;
}
20 changes: 20 additions & 0 deletions q2_problem.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//Question 2a
float do_it(char a,char b,char c);


//Question 2b
void print_a_number(int m);

//Question 2c

#include <stdio.h>
void print_msg( void );
main(){
print_msg("This is a message to print");//The print_msg function does not take arguments on it.
return 0;
}
void print_msq( void ) //This is supposed to be print_msg not print_msq
{
puts("This is a message to print");
return 0; // This is unexpected because the return type was already specified as 'void'
}
27 changes: 27 additions & 0 deletions q3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//Quetion 3a
long array[50];

//Question 3b
long array[49] = 123.456;

//Question 3c
for (x = 0; x < 100; x++) // x = values 0,1,2,3,4,5..........99( x values increasing from 1 t0 99)

//Question 3d
for (ctr = 2; ctr < 10; ctr += 3) // ctr value = (2,5,8)

//Question 3e
#include<stdio.h>
int main()
{
int counter, c = 1;
while ( c <= 100) {
counter = i;
c += 3;
}
return o;
}

//Qustion 3f
for (counter = 1; counter < MAXVALUES; counter++ ); //the for loop was terminated
printf("\nCounter = %d", counter);//The function did not have braces
50 changes: 50 additions & 0 deletions q4b.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

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

int results[] = {};
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_first[n], array_second[n];
printf("Enter First array: \n");

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

printf("Enter Second array: \n");

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

int *y;
y = addarrays(array_first, array_second, n);
printf("array one: ");
for (i=0; i < n ; i++) {
printf("%d,", array_first[i]);
}
printf("\n array two: ");
for (i=0; i < n; i++){
printf("%d,", array_second[i]);
}
printf("\nresults array: ");
for (i=0; i < n; i++){
printf("%d,", y[i]);
}
return 0;
}

int *addarrays(int array1[], int array2[], int n) {
int i = 0;
for (i = 0; i < n; i++) {
results[i] = array1[i] + array2[i];
}
int *z;
z = results;
return z;
}