-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c84e8ce
commit 020584c
Showing
24 changed files
with
140 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This file contains tests for the system arguments (argv). | ||
// | ||
// TODO: 'argc' and 'argv' are hard-coded. | ||
|
||
#include <stdio.h> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
int c; | ||
|
||
printf("Number of command line arguments passed: %d\n", argc); | ||
|
||
for (c = 1; c < argc; c++) | ||
printf("%d. Command line argument passed is %s\n", c + 1, argv[c]); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// This file contains tests for assert.h. | ||
|
||
#include <stdio.h> | ||
#include <assert.h> | ||
|
||
void print_number(int *myInt) | ||
{ | ||
assert(myInt != NULL); | ||
printf("%d\n", *myInt); | ||
} | ||
|
||
int main() | ||
{ | ||
int a = 10; | ||
int *b = NULL; | ||
int *c = NULL; | ||
|
||
b = &a; | ||
|
||
print_number(b); | ||
print_number(c); | ||
|
||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Test for math.h. | ||
|
||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
int n, c; | ||
|
||
printf("Enter a number\n"); | ||
scanf("%d", &n); | ||
|
||
if (n == 2) | ||
printf("Prime number.\n"); | ||
else | ||
{ | ||
for (c = 2; c <= n - 1; c++) | ||
{ | ||
if (n % c == 0) | ||
break; | ||
} | ||
if (c != n) | ||
printf("Not prime.\n"); | ||
else | ||
printf("Prime number.\n"); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
// This program actually still works without including stdio.h but it should be | ||
// here for consistency. | ||
|
||
#include <stdio.h> | ||
|
||
void test_putchar() | ||
{ | ||
char c; | ||
for (c = 'A'; c <= 'Z'; c++) | ||
putchar(c); | ||
putchar(c); | ||
} | ||
|
||
void test_puts() | ||
{ | ||
puts("c2go"); | ||
} | ||
|
||
void test_printf() | ||
{ | ||
printf("Hello World\n"); | ||
} | ||
|
||
int main() | ||
{ | ||
test_putchar(); | ||
test_puts(); | ||
test_putchar(); | ||
test_puts(); | ||
test_printf(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Tests for structures. | ||
|
||
#include <stdio.h> | ||
|
||
struct programming | ||
{ | ||
float constant; | ||
char *pointer; | ||
}; | ||
|
||
int main() | ||
{ | ||
struct programming variable; | ||
char *s = "Programming in Software Development."; | ||
|
||
variable.constant = 1.23; | ||
variable.pointer = s; | ||
|
||
printf("%f\n", variable.constant); | ||
printf("%s\n", variable.pointer); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
int number; | ||
|
||
printf("Enter an integer\n"); | ||
scanf("%d", &number); | ||
|
||
printf("Integer entered by you is %d\n", number); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
int value = 1; | ||
|
||
while (value <= 3) | ||
{ | ||
printf("Value is %d\n", value); | ||
value++; | ||
} | ||
|
||
return 0; | ||
} |