-
Notifications
You must be signed in to change notification settings - Fork 0
c in 24h part 1 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Goodwitch68
wants to merge
17
commits into
master
Choose a base branch
from
TYC_in_24_H
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e3b1991
TYC_Hour_2
Goodwitch68 16e4873
H2_E2 done
Goodwitch68 228e62f
H2_E3 done
Goodwitch68 3b8491d
H3_E5 done
Goodwitch68 cc59587
H4_C1 done
Goodwitch68 e2548d6
H4_C2 done
Goodwitch68 6bb2b86
H4_C4 done
Goodwitch68 91d30fb
H4_C5 done
Goodwitch68 ce56711
H5 is done
Goodwitch68 022f5d6
H6 done
Goodwitch68 1cf6e57
H7 done
Goodwitch68 c6c06c1
H4_E5 done. Ezt eddig nem commitoltam volna?
Goodwitch68 7cc5fab
Ez csak egy kísérlet volt...
Goodwitch68 5c7a41a
code review session
Goodwitch68 d99657c
Cleanup H4, H6, H7
Goodwitch68 3139052
Delete TYC_Hour_2
Goodwitch68 28a54a5
H7_E1 delete useless comment
Goodwitch68 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,8 @@ | ||
| 1: /* 02L01.c: This is my first C program */ | ||
| 2: #include <stdio.h> | ||
| 3: | ||
| 4: main() | ||
| 5: { | ||
| 6: printf ("Howdy, neighbor! This is my first C program.\n"); | ||
| 7: return 0; | ||
| 8: } | ||
This file contains hidden or 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,8 @@ | ||
| #include <stdlib.h> | ||
| #include <stdio.h> | ||
|
|
||
| void main() { | ||
| printf("It's fun to write my own program in C.\n"); | ||
| exit(0); | ||
|
|
||
| } |
This file contains hidden or 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,7 @@ | ||
| #include <stdlib.h> | ||
| #include <stdio.h> | ||
|
|
||
| void main() { | ||
| printf("\nHowdy, neighbor!\nThis is my first C program.\n"); | ||
| return 0; | ||
| } |
This file contains hidden or 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,10 @@ | ||
| #include <stdio.h> | ||
| /* This function multiplicate two integers and returns the result */ | ||
| int integer_mult(int x, int y) { | ||
| return x * y; | ||
| } | ||
|
|
||
| int main() { | ||
| printf("3 times 5 is %d.\n", integer_mult(3, 5)); | ||
| return 0; | ||
| } |
This file contains hidden or 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,6 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() { | ||
| printf("The numeric value of Z is: %d, the same of z is: %d.", 'Z', 'z'); | ||
| return 0; | ||
| } |
This file contains hidden or 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,6 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() { | ||
| printf("The ASCII value of 72 is character: %c, the 104 is character: %c.", 72, 104); | ||
| return 0; | ||
| } |
This file contains hidden or 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,7 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() { | ||
| double dbl_num = 123.456; | ||
| printf("Floating is: %f, scientific is: %e.", dbl_num, dbl_num); | ||
| return 0; | ||
| } |
This file contains hidden or 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,6 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() { | ||
| printf("The numeric value of '\n' is: %d.", '\n'); | ||
| return 0; | ||
| } |
This file contains hidden or 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,33 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() { | ||
| //1. feladat | ||
| printf("%c%c%c\n", 'B', 'y', 'e'); | ||
| //2. feladat | ||
| int number1 = 123; | ||
| float number2 = 123.456; | ||
| printf("%d\n%f\n", number1, number2); | ||
| printf("%-8d\n%-8f\n", number1, number2); | ||
| //3. feladat | ||
| int number3 = -15; | ||
| int number4 = 150; | ||
| int number5 = 1500; | ||
| printf( | ||
| "-15 hexadecimális formában: %x,\n 150 hexadecimális alakja: %x,\n1500 hexadecimális alakja: %x\n", | ||
| number3, | ||
| number4, | ||
| number5 | ||
| ); | ||
| //4. feladat | ||
| int ch; | ||
| setbuf(stdout, NULL); | ||
| printf("Please type in one character:\n"); | ||
| ch = getchar(); | ||
| printf("The character you just entered is:\n"); | ||
| putchar (ch); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| //5. feladat | ||
| // the header stdio.h is missing |
This file contains hidden or 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,51 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() { | ||
| //1. feladat | ||
| //Given x = 1 and y = 3, write a program to print | ||
| //out the results of these expressions: x += y, | ||
| //x += -y, x -= y, x -= -y, x *= y, and x *= -y. | ||
| int x = 1; | ||
| int y = 3; | ||
| printf("x += y értéke:%d\n", x += y); | ||
| x = 1; | ||
| printf("x += -y értéke:%d\n", x += (-y)); | ||
| x = 1; | ||
| printf("x -= y értéke:%d\n", x -= y); | ||
| x = 1; | ||
| printf("x -= -y értéke:%d\n", x -= (-y)); | ||
| x = 1; | ||
| printf("x *= y értéke:%d\n", x *= y); | ||
| x = 1; | ||
| printf("x *= -y értéke:%d\n", x *= (-y)); | ||
|
|
||
| //2. feladat | ||
| //Given x = 3 and y = 6, what is the value of z after the expression | ||
| //z = x * y == 18 is executed? | ||
| // answer is '1' | ||
Goodwitch68 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| //3. feladat | ||
| x = 1; | ||
| printf("x++ produces: %d\n", x++); | ||
| printf("Now x contains: %d\n", x); | ||
|
|
||
| //4. feladat | ||
| x = 1; | ||
| printf("x = x++ produces: %d\n", x = x++); | ||
| printf("Now x contains: %d\n", x); | ||
| // x returns 1, bec x=x++ means: x++ returns 1 | ||
Goodwitch68 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /*5. feladat | ||
| #include <stdio.h> | ||
| main() | ||
| { | ||
| int x, y; | ||
| x = y = 0; | ||
| printf("The comparison result is: %d\n", x = y); [x==y is the proper comparison] | ||
| return 0; | ||
| } | ||
| */ | ||
| //setbuf(stdout, NULL); | ||
This file contains hidden or 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,71 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() { | ||
| //1.-2. feladat | ||
| //What is the difference between | ||
| //the following two pieces of code? | ||
| // for (i=0, j=1; i<8; i++, j++) | ||
| // printf("%d + %d = %d\n", i, j, i+j); | ||
| // | ||
| //for (i=0, j=1; i<8; i++, j++); | ||
| //printf("%d + %d = %d\n", i, j, i+j); | ||
|
|
||
| //in the line 11 there is an "empty" loop, it does not anyting | ||
|
|
||
| //2. feladat | ||
| //Write a program that contains the two pieces of | ||
| //code shown in exercise 1, and then execute the program. | ||
| //What are you going to see on the screen? | ||
| int i; | ||
| int j; | ||
| printf("2. feladat\n"); | ||
| for (i = 0, j = 1; i < 8; i++, j++) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. akkor is legyen kinn a kapcsos zárójel a for loopnál, ha csak egy sorból áll a teste. Ugyanez igaz az if-re, a while-ra, stb. Vagy itt pont ez volt a feladat? |
||
| printf("%d + %d = %d\n", i, j, i+j); | ||
|
|
||
|
|
||
| for (i = 0, j = 1; i < 8; i++, j++); | ||
| printf("%d + %d = %d\n", i, j, i+j); | ||
| //the 2. loop doesn't do anything | ||
|
|
||
| //3. feladat | ||
| //Rewrite the program in Listing 7.4. This time, | ||
| //you want the for statement to keep looping until | ||
| //the user enters the character K. | ||
| int c; | ||
| setbuf(stdout, NULL); | ||
| printf("\n3. feladat\n"); | ||
| printf("Enter a character:\n(enter K to exit)\n"); | ||
| c = ' '; | ||
| while (c = getc(stdin) != 'K') { | ||
| putchar(c); | ||
| } | ||
| printf("\nOut of the for loop. Bye!\n"); | ||
|
|
||
|
|
||
| //4. feladat | ||
| //Rewrite the program in Listing 7.6 by replacing | ||
| //the do-while loop with a for loop. | ||
| printf("\n4. feladat\n"); | ||
| for (i = 65; i < 72; i++) { | ||
| printf("The numeric value of %c is %d.\n", i, i); | ||
| } | ||
|
|
||
| //5. feladat | ||
| //Rewrite the program in Listing 7.7. | ||
| //This time, use a while loop as the outer loop | ||
| //and a do-while loop as the inner loop. | ||
| i = 1; | ||
| printf("\n5. feladat\n"); | ||
| while (i <= 3) { // outer loop | ||
| printf("The start of iteration %d of the outer loop.\n", i); | ||
| j = 1; | ||
| do { | ||
| printf(" Iteration %d of the inner loop.\n", j); | ||
| j++; | ||
| } while (j <= 4); | ||
| printf("The end of iteration %d of the outer loop.\n", i); | ||
| i++; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
This file contains hidden or 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,7 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main(){ | ||
| //printf("%c%c%c\n",'B'^0b00100000, 'y'^0b00100000, 'e'^0b00100000); | ||
| puts("%c%c%c\n", 'e'); | ||
| return 0; | ||
| } |
This file contains hidden or 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,27 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() | ||
| { | ||
| int x = 1; | ||
| printf("x = x + 1 értéke:%d\n",x = x + 1); | ||
| printf("Now x contains: %d\n", x); | ||
|
|
||
| x = 1; | ||
| printf("x++ produces: %d\n", x++); | ||
| printf("Now x contains: %d\n", x); | ||
|
|
||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /*5. feladat | ||
| #include <stdio.h> | ||
| main() | ||
| { | ||
| int x, y; | ||
| x = y = 0; | ||
| printf("The comparison result is: %d\n", x = y); [x==y is the proper comparison] | ||
| return 0; | ||
| } | ||
| */ | ||
| //setbuf(stdout, NULL); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printfután ne legyen space