Skip to content

Commit 98390a9

Browse files
committed
hafta 3-4
1 parent 59464bc commit 98390a9

8 files changed

+187
-0
lines changed

week3/if/exp1-sayi-fark.c

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main() {
5+
6+
// Cikti ne olur ?
7+
8+
int A, B, sonuc;
9+
printf("A degerini giriniz: ");
10+
scanf("%d", &A);
11+
12+
printf("\nB degerini giriniz: ");
13+
scanf("%d", &B);
14+
15+
printf("\n");
16+
if (A==B){
17+
sonuc=A-B;
18+
printf("Sonuc: %d\n", sonuc);
19+
} else if (A>B){
20+
sonuc=A-B;
21+
printf("Sonuc: %d\n", sonuc);
22+
} else {
23+
sonuc=B-A;
24+
printf("Sonuc: %d\n", sonuc);
25+
}
26+
return 0;
27+
}

week3/if/exp3-tek-cift.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int x;
7+
printf("x sayisini giriniz: ");
8+
scanf("%d", &x);
9+
printf("\n");
10+
if (x%2==0)
11+
printf("Sayi cift sayidir.\n");
12+
else
13+
printf("Sayi tek sayidir.\n");
14+
return 0;
15+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
char harf;
7+
printf("Kontrol etmek icin harf giriniz: ");
8+
scanf("%c",&harf);
9+
10+
if((harf >= 'a' && harf <= 'z') || (harf >= 'A' && harf <= 'Z'))
11+
{
12+
printf("\nGirdiginiz '%c' harfi alfabede mevcuttur...\n",harf);
13+
}
14+
else
15+
{
16+
printf("\nGirdiginiz '%c' harfi alfabede mevcut degildir...\n",harf);
17+
}
18+
return 0;
19+
}

week3/if/exp7-mil-km-donustur.c

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <stdio.h>
2+
#define ORAN 1.609344
3+
int main()
4+
{
5+
char secim;
6+
float mesafe, sonuc;
7+
8+
printf("Hangisi? (Mil: M/m veya Kilometre: K/k): ");
9+
scanf("%c", &secim);
10+
printf("\n");
11+
12+
if((secim=='M')||(secim=='m'))
13+
{
14+
printf("Kac mil yol aldiniz: ");
15+
scanf("%f", &mesafe);
16+
sonuc=mesafe*ORAN;
17+
printf("\n%6.2f Mil = %6.2f Kilometre\n", mesafe, sonuc);
18+
}
19+
else if((secim=='K')||(secim=='k'))
20+
{
21+
printf("Kac kilometre yol aldiniz: ");
22+
scanf("%f", &mesafe);
23+
sonuc=mesafe/ORAN;
24+
printf("\n%6.2f Kilometre = %6.2f Mil\n", mesafe, sonuc);
25+
}
26+
else
27+
printf("Yanlis harf girildi...\n");
28+
return 0;
29+
}

week4/switch-case/exp4-ay-tahmin.c

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main() {
5+
int x;
6+
printf("Bir ay giriniz: ");
7+
scanf("%d",&x);
8+
9+
switch(x){
10+
case 12 :
11+
case 1 :
12+
case 2 :
13+
printf("Girdiginiz ay kis mevsimindedir.\n");
14+
break;
15+
case 3 :
16+
case 4 :
17+
case 5 :
18+
printf("Girdiginiz ay ilkbahar mevsimindedir.\n");
19+
break;
20+
break;
21+
case 6 :
22+
case 7 :
23+
case 8 :
24+
printf("Girdiginiz ay yaz mevsimindedir.\n");
25+
break;
26+
case 9 :
27+
case 10 :
28+
case 11 :
29+
printf("Girdiginiz ay sonbahar mevsimindedir.\n");
30+
break;
31+
default :
32+
printf("Yanlis bir giris yaptiniz\n");
33+
}
34+
return 0;
35+
}
36+
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int secim;
7+
float a,b;
8+
9+
printf("********* MENU ************\n");
10+
printf("1.TOPLAMA\n");
11+
printf("2.CIKARTMA\n");
12+
printf("3.CARPMA\n");
13+
printf("4.BOLME\n\n");
14+
15+
printf("ISLEM NO GIRINIZ--> ");
16+
scanf("%d",&secim);
17+
printf("\n");
18+
19+
printf("1.sayi: ");
20+
scanf("%f",&a);
21+
printf("2.sayi: ");
22+
scanf("%f",&b);
23+
24+
switch(secim)
25+
{
26+
case 1: printf("Sonuc= %5.2f\n",a+b); break;
27+
case 2: printf("Sonuc= %5.2f\n",a-b); break;
28+
case 3: printf("Sonuc= %5.2f\n",a*b); break;
29+
case 4: printf("Sonuc= %5.2f\n",a/b); break;
30+
default: printf("islem gecersiz\n");
31+
}
32+
return 0;
33+
}

week4/ternary-inline/exp3-tek-cift.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int x;
7+
printf("x sayisini giriniz: ");
8+
scanf("%d", &x);
9+
printf("\n");
10+
11+
x%2==0 ? printf("Sayi cift sayidir.\n") : printf("Sayi tek sayidir.\n");
12+
13+
return 0;
14+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int x;
7+
printf("x sayisini giriniz: ");
8+
scanf("%d", &x);
9+
printf("\n");
10+
11+
x>0 ? printf("Sayi pozitif.\n") : x < 0 ? printf("Sayi negatif.\n") : printf("Sayi sifir.\n");
12+
13+
return 0;
14+
}

0 commit comments

Comments
 (0)