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
14 changes: 14 additions & 0 deletions Question 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdio.h>d
int x=1;
main()
{

if(x==1)
printf("x equals 1");
else
{
printf("x does not equal 1");
}
return 0;
}

21 changes: 21 additions & 0 deletions Question 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
2a float do_it(char A, char B, char C)

2b void print_a_number(int a)

2c #include <stdio.h>
void print_msg( void );
main(){
print_msg("This is a message to print");
return 0;
}
void print_msq( void )
{
puts("This is a message to print");
return 0;
}

/*The function name in the header file is different from that in the program body that is; print_msg and print_msq are different yet they
are supposed to be the same in a given program.*/

/*The function has arguments yet the declaration indicates that the function has no arguments.*/

20 changes: 20 additions & 0 deletions Question 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
3a long a[50];

3b a[49]=123.456

3c The values of x; 0 to 99

3d The values of ctr are; 2,5,8

3e
int i=1;
while(i<100)
{
printf("%d\n",i);
i+=3;
}


3f for (counter = 1; counter < MAXVALUES; counter++ );/*The for statement is not supposed to be terminated in C*/
printf("\nCounter = %d", counter);

52 changes: 52 additions & 0 deletions Question 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
4a
/*void addarrays(int N, int x[],int y[],int z[]){
int i;
for(i=0; i<N; I++)

{
z[i]=x[i]+y[i];
}

}
*/


4b
#include <stdio.h>
#include <stdlib.h>
int N, i;
int *addarrays(int N,int x[],int y[],int z[]){
int i;
for(i=0; i<N; i++)
{
z[i]=x[i]+y[i];
}
return 0;
}
void arrays_elements(int N, int a[]){
for (i=0; i<N ; i++)
printf("\n%d",a[i]);
}
void print_elements(int N, int a[]){
for(i=0; i<N; i++){
printf("enter element");
scanf("%d",&a[i]);}
}
int main(){
int x[N], y[N],z[N];
printf("enter size of the arrays");
scanf("%d",&N);
printf("enter elements of the 1st array:\n");
print_elements(N,x);
printf("enter elements of the array two:\n");
print_elements(N,y);
int*p;
p=addarrays(N,x,y,z);
printf("elements of array 1 are:\n");
print_elements(N,x);
printf("elements of array 2 are:\n ");
print_elements(N,y);
printf("elements of array that contain sum are:\n");
print_elements(N,z);
return 0;
}