Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.6 kB
58
Indexable
Never
#include <stdio.h>

struct Not{
	int		ders_notu;
	char	ders_adi[32];
};

struct Genel_Durum{
	int		not_ortalamasi;
	int		gecti;	
};

struct Ogrenci{
	char				isim[32];
	int					sinif;
	int					numara;
	struct Not			n_bilgi[2];
	struct Genel_Durum	g_bilgi;
};

int	main()
{
	struct Ogrenci Ogrenciler[5];

	for(int i = 0; i < 5; i++)
	{
		int	not1, not2;
		printf("*** 1. Ogrecinin Bilgilerini Giriniz ***\n");
		printf("Ogrencinin Adi-Soyadi: ");
		scanf("%s", Ogrenciler[i].isim);
		printf("Ogrencinin Sinif Numarasi: ");
		scanf("%d", &Ogrenciler[i].sinif);
		printf("Ogrencinin Numarasi: ");
		scanf("%d", &Ogrenciler[i].numara);
		printf("Ogrencinin Ilk Dersinin Adi: ");
		scanf("%s", &Ogrenciler[i].n_bilgi[0].ders_adi);
		printf("Ogrencinin Ilk Dersinin Notu: ");
		scanf("%d", &not1);
		printf("Ogrencinin Ikinci Dersinin Adi: ");
		scanf("%s", &Ogrenciler[i].n_bilgi[1].ders_adi);
		printf("Ogrencinin Ikinci Dersinin Notu: ");
		scanf("%d", &not2);
		Ogrenciler[i].n_bilgi[0].ders_notu = not1;
		Ogrenciler[i].n_bilgi[1].ders_notu = not2;
		Ogrenciler[i].g_bilgi.not_ortalamasi = not1 + not2 / 2;
		Ogrenciler[i].g_bilgi.gecti = Ogrenciler[i].g_bilgi.not_ortalamasi  >= 50 ? 1 : 0; 
	}
	FILE *ptr = fopen("notlar.txt", "w");
	fputs("Ad\tSinif\tNumara\tNot Ort.\tDurum\n", ptr);
	for(int i = 0; i < 5; i++)
		fprintf(ptr, "%s\t%d\t%d\t%d\t%s\n", Ogrenciler[i].isim, Ogrenciler[i].sinif, Ogrenciler[i].numara, Ogrenciler[i].g_bilgi.not_ortalamasi, Ogrenciler[i].g_bilgi.gecti ? "Gecti" : "Kaldi");
	fclose(ptr);
	return (0);
}
Leave a Comment