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
11 changes: 11 additions & 0 deletions question1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//program without errors
#include <stdio.h>
int x= 2;
main()
{
if( x == 1)
printf(" x equals 1" );
else
printf(" x does not equal 1");
return 0;
}
32 changes: 32 additions & 0 deletions question2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//part a
#include <stdio.h>
float do_it(char x,char y,char z);
int main(){

return 0;
}



/* part b*/
#include <stdio.h>
void print_a_number(int a);
int main (){

return 0;
}


/* part c*/
#include <stdio.h>
void print_msg( void );
main(){
print_msg("This is a message to print");// the function here is not known

return 0;
}
void print_msq( void )
{
puts("This is a message to print");
return 0; //a void function returns nothing
}
32 changes: 32 additions & 0 deletions question3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <stdio.h>

int main(){
long array[50];

array[49]=123.456;

return 0;
}

// part b
x will be equal to 99

// part c
ctr will be 8

// part d
#include <stdio.h>

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

}
return 0;
}

// part
for (counter = 1; counter < MAXVALUES; counter++ ); // the termination of the for loop here means that the printf function is not going to be looped through.
printf("\nCounter = %d", counter);
33 changes: 33 additions & 0 deletions question4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <stdio.h>
void addarrays(int [], int[], int*);
int main(){
int counter;

int a[] = {1,2,3};
int b[] = {8,5,8};
int size = (int)sizeof(b)/4; // i divided by 4 because the size of function gives the total number of bytes in the array
int c[size];
// for (counter = 1; counter < MAXVALUES; counter++ )
// printf("\nCounter = %d", counter);
if ((int)sizeof(a)==(int)sizeof(b)){
addarrays(a,b,c);
for (counter = 0; counter < size; counter++ ){

printf("\n %d", c[counter]);
}

}else{
printf("input array of same size");
}


return 0;
}

void addarrays(int a[], int b[], int* c){
int i ;
for (i=0; i<sizeof(a) ; i++){
*c = a[i] + b[i];
c++;
}
}