29 Temmuz 2013 Pazartesi

C Programlamada Görsel Hesap Makinesi Örneği

Sponsorlu Bağlantılar
#include<stdio.h>
#include<windows.h>
int secim;
void rengim(int renk)
{
 HANDLE hStdout;
 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
 SetConsoleTextAttribute(hStdout, renk);
}
int topla(int sayi1 ,int sayi2)
{
 return (sayi1+sayi2);
}
int cikar(int sayi1 ,int sayi2)
{
 return (sayi1-sayi2);
}
int carp(int sayi1 ,int sayi2)
{
 return (sayi1*sayi2);
}
int bol(int sayi1 ,int sayi2)
{
 if(sayi2!=0)
 return (sayi1/sayi2);
}
void gotoxy(short x, short y)
{
 HANDLE hConsoleOutput;
 COORD Cursor_Pos={x-1,y-1};
 hConsoleOutput=GetStdHandle(STD_OUTPUT_HANDLE);
 SetConsoleCursorPosition(hConsoleOutput,Cursor_Pos);
}
void cerceve(int x1,int x2,int y1,int y2)
{
 int i,j;
 for(i=x1;i<=x2;i++)
 {
 gotoxy(i,y1);printf("%c",196);
 gotoxy(i,y2);printf("%c",196);
 }
 for(j=y1;j<=y2;j++)
 {
 gotoxy(x1,j);printf("%c",179);
 gotoxy(x2,j);printf("%c",179);
 }
 gotoxy(x1,y1);printf("%c",218);
 gotoxy(x2,y1);printf("%c",191);
 gotoxy(x2,y2);printf("%c",217);
 gotoxy(x1,y2);printf("%c",192);
}
void baslangic()
{
 int i,j;
 gotoxy(25,20);printf("");
 gotoxy(20,14);printf("HESAP MAKINASI YUKLENIYOR");
 for(j=15;j<=50;j++)
 {
 gotoxy(j,16);printf("%c",196);
 gotoxy(j,18);printf("%c",196);
 }
 for(i=15;i<=50;i++)
 {
 rengim(4);
 gotoxy(i,17);printf("%c",177);
 Sleep(100);
 rengim(7);
 }
}
void menu()
{
 system("cls");
 cerceve(1,15,1,15);
 rengim(4);
 gotoxy(2,2);printf("ISLEMLER\n");
 gotoxy(2,3);printf("--------");
 rengim(5);
 gotoxy(2,4);printf("1-TOPLAMA");
 rengim(6);
 gotoxy(2,6);printf("2-CIKARMA");
 rengim(3);
 gotoxy(2,8);printf("3-CARPMA");
 rengim(8);
 gotoxy(2,10);printf("4-BOLME");
 rengim(7);
 gotoxy(2,12);printf("Seciminiz:");
 scanf("%d",&secim);
}
main()
{
 int say1,say2;
 baslangic();
 Sleep(300);
 menu();
 cerceve(25,60,1,20);
 gotoxy(30,2);printf("1.sayiyi gir: ");scanf("%d",&say1);
 gotoxy(30,3);printf("2.sayiyi gir: ");scanf("%d",&say2);
 switch(secim)
 {
 case 1:
 {
 rengim(5);
 gotoxy(35,6);printf("%d",say1);
 gotoxy(35,8);printf("%d",say2);
 gotoxy(30,9);printf("+");
 gotoxy(30,10);printf("---------");
 gotoxy(35,11);printf("%d",topla(say1,say2));
 break;
 }
 case 2:
 {
 rengim(6);
 gotoxy(35,6);printf("%d",say1);
 gotoxy(35,8);printf("%d",say2);
 gotoxy(30,9);printf("-");
 gotoxy(30,10);printf("---------");
 gotoxy(35,11);printf("%d",cikar(say1,say2));
 break;
}
 case 3:
 rengim(7);
 {
 gotoxy(35,6);printf("%d",say1);
 gotoxy(35,8);printf("%d",say2);
 gotoxy(30,9);printf("x");
 gotoxy(30,10);printf("---------");
 gotoxy(35,11);printf("%d",carp(say1,say2));
 break;
 }
 case 4:
 {
 rengim(8);
 gotoxy(35,6);printf("%d",say1);
 gotoxy(34,7);printf("----");
 gotoxy(35,8);printf("%d",say2);
 gotoxy(30,9);printf("=");
 gotoxy(30,10);printf("---------");
 gotoxy(35,11);printf("%d",bol(say1,say2));
 break;
 }
 default:
 {
 printf("yanlis secim");
 }
 }
 gotoxy(1,24);
getchar();
getchar();

}
Sponsorlu Bağlantılar

Hiç yorum yok:

Yorum Gönder