Skip to content
Open
8 changes: 8 additions & 0 deletions helloworld/.c
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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printf után ne legyen space

7: return 0;
8: }
8 changes: 8 additions & 0 deletions helloworld/H2_E2.c
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);

}
7 changes: 7 additions & 0 deletions helloworld/H2_E3.c
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;
}
10 changes: 10 additions & 0 deletions helloworld/H3_E5.c
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;
}
6 changes: 6 additions & 0 deletions helloworld/H4_E1.c
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;
}
6 changes: 6 additions & 0 deletions helloworld/H4_E2.c
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;
}
7 changes: 7 additions & 0 deletions helloworld/H4_E4.c
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;
}
6 changes: 6 additions & 0 deletions helloworld/H4_E5.c
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;
}
33 changes: 33 additions & 0 deletions helloworld/H5_E1.c
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
51 changes: 51 additions & 0 deletions helloworld/H6_E1.c
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'

//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

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);
71 changes: 71 additions & 0 deletions helloworld/H7_E1.c
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++)
Copy link
Collaborator

Choose a reason for hiding this comment

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

7 changes: 7 additions & 0 deletions helloworld/ascii_bitwise.c
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;
}
27 changes: 27 additions & 0 deletions helloworld/xpp.c
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);