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
32 changes: 32 additions & 0 deletions number 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Number 2a solution;


float do_it(char A,char B,char C)


Number 2b solution;


void print_a_number (int a)

number 2c sln;

#include <stdio.h>
void print_msg(void);

main()
{
print_msg();
return 0;
}

void print_msg(void)
{
puts("This is a message to print");
return 0;
}
/*the function name must be the same. it was wrong to put print_msq instead of print_msg*/

/* so the above program corrected prints 'This is a message to print'*/
/*the funtion has arguments yet the declaration function had no arguments*/

96 changes: 96 additions & 0 deletions number 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Number 3a solution;

float a[50]


Number 3b solution;

a[49]=123.456;



number 3c sln;

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

int main()
{
int x;
for(x=0;x<100;x++)
printf("%d\n",x);
return 0;
}

/* 0<=x<=99*/


number 3d sln;

#include <stdio.h>

int main()
{
int ctr;

for(ctr=2;ctr<10;ctr+=3)

printf("%d\n",ctr);

return 0;
}
/*the value of ctr is 2,5 and 8*/


number 3e sln;

#include <stdio.h>

int main()
{
int b=1;

while (b<=100)
{
printf("%d\n",b);

b+=3;

}

return 0;
}
/*the values of x ranged 1<=x<=100*/


number 3f sln;


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

int main()
{
int counter

for(counter=1; counter<MAXVALUES;counter ++);

printf("\nCounter=%d",counter);

}
/*'counter' undeclared, its supposed to declared as an int with ';' at the end*/

/*'MAXVALUES' undeclared earlier in the function*/

/*the for loop should not be terminated*/

/*the printf function written wrongly;

first '\n' came before %d

second 'Counter' was written with a capital later instead of a small letter and also equaled to %d*/





57 changes: 57 additions & 0 deletions number 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
number 4a sln;

void addarrays(int N, int x[],int y[],int z[]){
int i;
for(i=0; i<N; I++)

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

}


number 4b sln;


#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;
}



13 changes: 13 additions & 0 deletions question 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
int x=1;
main()
{
if(x==1)
printf("x equals 1");
else
printf("x does not equal 1");
return 0;
}

/* the program initially had 'if (x=1)' which is simply an assignment operator not the equals sign*/
/* the word 'otherwise' was used instead of 'else'*/