Kod:
//Toplama işlemi
#include <iostream>
using namespace std;
int main() {
double a,b;
cout << "Birinci Sayi : ";
cin >> a;
cout << "Ikinci Sayi : ";
cin >> b;
cout << "Toplam : " << a+b;
system("PAUSE");
return 0;
}
Kod:
//Adres Defteri
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define SIZE 100
struct list_type {
char adi[10];
char soyadi[10];
char sehir[12];
char telefon[11];
} list[SIZE];
int menu(voıd);
voıd init_list(voıd);
voıd enter(voıd);
voıd arama(voıd);
voıd iptal(voıd);
voıd display(voıd);
voıd save(voıd);
voıd load(voıd);
voıd main(voıd) {
char choice;
init_list();
for(;;) {
choice = menu();
switch(choice) {
case 'i':iptal();break;
case 'a':arama();break;
case 'g':enter();break;
case 'l':display();break;
case 's':save();break;
case 'c':load();break;
case 'q':exit(0);
}
}
}
voıd init_list(voıd) {
register int t;
for(t=0; t<SIZE; t++)
*list[t].adi = İ\0';
}
voıd enter(voıd) {
register int i;
for(i=0; i<SIZE; i++)
if (!*list[i].adi)
break;
if (i==SIZE){
printf("Liste dolu\n");
return;
}
clrscr();
printf("Adiniz.....:");
gets(list[i].adi);
printf("Soyadi.....:");
gets(list[i].soyadi);
printf("Sehir......:");
gets(list[i].sehir);
printf("Telefon....:");
gets(list[i].telefon);
}
voıd arama(voıd) {
char ara[10];
FILE *fp;
register int t;
int a;
clrscr();
printf("\n Aradiginiz Kisinin Adini Giriniz:");
gets(ara);
for(t=0;t<SIZE;t++) {
if (strstr(list[t].adi,ara)) {
clrscr;
printf("\n Adi=%s",list[t].adi);
printf("\n Soyadi=%s",list[t].soyadi);
printf("\n Sehir=%s",list[t].sehir);
printf("\n Telefon=%s",list[t].telefon);
getch();
a=1;
}
}
if (a!=1) {
printf("\n Aradiginiz Kayit Yok");
getch();
}
}
voıd iptal(voıd) {
char ara[10];
register int t;
int a;
clrscr();
printf("Sileceginiz Kisinin Adini Girin:");
gets(ara);
for(t=0;t<SIZE;t++) {
if(strstr(list[t].adi,ara)) {
a=1;
*list[t].adi=İ\0';
*list[t].soyadi=İ\0';
*list[t].sehir=İ\0';
*list[t].telefon=İ\0';
}
}
if (a!=1)
printf("\n Sileceginiz Kayit Bulunamadi");
}
voıd display(voıd) {
register int t;
for(t=0;t<SIZE;t++) {
if (*list[t].adi) {
clrscr();
printf("%s \n",list[t].adi);
printf("%s \n",list[t].soyadi);
printf("%s \n",list[t].sehir);
printf("%s \n",list[t].telefon);}}
getch();
}
voıd save(voıd) {
FILE *fp;
register int i;
if((fp=fopen("maillist","wb"))==NULL) {
printf("\n dosya acilamiyor\n");
return;
}
for(i=0; i<SIZE; i++)
if(*list[i].adi)
if (fwrite(&list[i],sizeof(struct list_type),1,fp) != 1)
printf("yazma hatasi!\n");
}
voıd load(voıd) {
FILE *fp;register int i;
if ((fp=fopen("maillist","rb")) == NULL) {
printf("dosya acilamiyor!\n");
return;
}
init_list();
for (i=0;i<SIZE;i++)
if(fread(&list[i],sizeof(struct list_type),1,fp) != 1) {
if (feof(fp)) return;
printf("dosya okuma hatasi!\n");}
}
int menu(voıd) {
char s[80];
do {
textcolor(14);
textbackground(1);
clrscr();
gotoxy(23,5);printf("TELEFON DEFTERI");
gotoxy(25,6);printf("(G)iris\n");
gotoxy(25,7);printf("(L)istele\n");
gotoxy(25,8);printf("(C)agir\n");
gotoxy(25,9);printf("(S)akla\n");
gotoxy(25,10);printf("(A)rama\n");
gotoxy(25,11);printf("(I)ptal\n");
gotoxy(25,12);printf("(C)ikis\n");
gotoxy(23,13);printf("Seciminiz.:");
gets(s);
} while(!strchr("GLCSAIQ",toupper(*s)));
return(*s);
}
Kod:
// Gün Sayımı
#include <stdio.h>
#include <time.h>
int main () {
struct tm *zaman;
time_t an;
int gun_say;
time(&an);
zaman = localtime(&an);
printf ("Su Anda Tarih Ve Saat : %s", asctime(zaman));
printf ("Kac Gun Ileriyi Gormek Istiyorsunuz? ");
scanf ("%d",&gun_say);
(*zaman).tm_mday = (*zaman).tm_mday + gun_say;
printf("%d Gun Sonra Saat ve Tarih : %s", gun_say, asctime(zaman));
system("PAUSE");
return 0;
}