diff --git a/3.c b/3.c new file mode 100644 index 00000000..c2b8cb75 --- /dev/null +++ b/3.c @@ -0,0 +1,39 @@ +#include +#include + +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; +} + diff --git a/4.c b/4.c new file mode 100644 index 00000000..98d84e05 --- /dev/null +++ b/4.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include + + +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; +} + + diff --git a/do_it.h b/do_it.h new file mode 100644 index 00000000..d462baf8 --- /dev/null +++ b/do_it.h @@ -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 diff --git a/doit.h b/doit.h new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/doit.h @@ -0,0 +1 @@ + diff --git a/done.h b/done.h new file mode 100644 index 00000000..59372d07 --- /dev/null +++ b/done.h @@ -0,0 +1 @@ +#define AGE 20 diff --git a/main.c b/main.c index d923aa60..03d8c24d 100644 --- a/main.c +++ b/main.c @@ -1,15 +1,31 @@ -#include -#include - -main(){ - char some_string[] = {}; - for (int i = 0; i < 20; ++i) { - scanf("%s", some_string); - if (some_string[i] == EOF) - { - break; - } - } - putchar(some_string); - -} \ No newline at end of file +#include +#include +#include +#include + +int main() +{ + + return 0; +} + +/* #include + 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*/ diff --git a/number 1 b/number 1 new file mode 100644 index 00000000..ca1a2b8d --- /dev/null +++ b/number 1 @@ -0,0 +1,15 @@ +#include +#include + +int x=1; +main() +{ + if (x==1){ + printf(" x equals 1 "); + } + else{ + printf(" x does not equal 1 "); + } + + return 0; +}