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
39 changes: 39 additions & 0 deletions 3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
long int digits[50];

digits[49] = 123.456;

printf("Values of X\n");
int x;
for (x=0; x<100; x++){
printf(" %d\t",x);
} /*final value of x is 99*/

printf("\n\nValues of ctr\n");
int ctr;
for (ctr=2; ctr<10; ctr+=3){
printf(" %d\t",ctr);
} /*final value of ctr is 8*/

printf("\n\nCounting from 1 to 100\n");
int count=1;
while(count<=100){
printf(" %d\t",count);
count +=3 ;
}

/* for (counter = 1; counter < MAXVALUES; counter ++);
printf("\n Counter = %d", counter); */

/* Problems in the above code are; MAXVALUES not declared to a specific data type,
counter not declared an integer, curly braces not used after the 'for' condition,
and the 'for loop' was wrongly terminated before printf statement.*/


return 0;
}

37 changes: 37 additions & 0 deletions 4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>


void addarrays(int arrayone[5],int arraytwo[5]){
int i;
int sum[5];
printf("\nTotal arrays\n");
for(i=0;i<5;i++){
sum[i] = arrayone[i] + arraytwo[i];
printf(" %d\t",sum[i]);
}
return;
}
int main()
{
int m;
int arrayA[5] = {23,24,31,40,5};
int arrayB[5] = {21,22,23,24,25};
printf("first array\n");
for(m=0;m<5;m++){
printf(" %d\t",arrayA[m]);
}
printf("\nsecond array\n");
for(m=0;m<5;m++){
printf(" %d\t",arrayB[m]);
}

addarrays(arrayA,arrayB);

return 0;
}


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_H(char x,char y,char z);

#endif // DO_IT_H
1 change: 1 addition & 0 deletions doit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions done.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define AGE 20
46 changes: 31 additions & 15 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
#include <ctype.h>
#include <stdio.h>

main(){
char some_string[] = {};
for (int i = 0; i < 20; ++i) {
scanf("%s", some_string);
if (some_string[i] == EOF)
{
break;
}
}
putchar(some_string);

}
#include <stdio.h>
#include <stdlib.h>
#include <do_it.h>
#include <print_a_number.h>

int main()
{

return 0;
}

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

/* Problems in the above program include; (1) the function print_msg() wrongly
has a return0 yet it cannot be returning anything, (2)the statement 'void'
in the parenthesis of the function print_msg() makes it unable to pass any
conditions in it. (3) Also the function print_msg() was misspelled when
prototyping. (4) The argument passed through print_msg() is undefined
to a specific data type*/
15 changes: 15 additions & 0 deletions number 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>

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

return 0;
}