IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası

IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası (https://www.ircforumlari.net/)
-   C ve C++ (https://www.ircforumlari.net/c-ve-c/)
-   -   Örnek Kodlamalar Buraya.. (https://www.ircforumlari.net/c-ve-c/320963-ornek-kodlamalar-buraya.html)

toXic 10 Mart 2010 14:30

Örnek Kodlamalar Buraya..
 
C ve C++ Üzerinde Yazmıs oldugunuz Kodlari, Örnek olmasi acisindan Burdan Gösterebilirsiniz.

Kod:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int salla,i,max,sonuc;
char cev;
void sayi();
void zaman();

int main(int argc, char** argv)
{
  zaman();
  basla:
  for(i=1;i<=6;i++)
  {
      sayi();
      printf("\n\t\tSayı :%2d = %2d",i,sonuc);
      usleep(1000000);
  }
  hata:
  printf("\n\ne = evet , h = hayır");
  printf("\nTekrar denemek istermisiniz ? : ");
  scanf("%s",&cev);
  if (cev=='E'||cev=='e')
  {
      goto basla;
  }
  else if(cev=='H'||cev=='h')
  {
      printf("\nBye...");
      goto son;
  }
  else if(cev!='E'||cev!='e'||cev!='H'||cev!='h')
  {
      printf("\nhatalı seçim...");
      goto hata;
  }
  son:
  return 0;
}

void sayi()
{
  int max=48;
  unsigned salla=time(NULL);
  srand(salla);
  sonuc=rand()%max+1;
}
void zaman()
{
  time_t rawtime;
  struct tm *timeinfo;
  time (&rawtime);
  timeinfo=localtime(&rawtime);
  printf("\n%s",asctime(timeinfo));
}

Sayisal loto, 10 numara gibi oyunlar icin Kullanabileceğiniz bir Program..

----------

2 sayinin toplamlarini alip ortalamasini bulan program.


Kod:

#include <stdio.h>
#include <conio.h>
 
main( )
{
int ibo1, ibo2;
int ortalama;
ortalama = ( ibo1 + ibo2 ) / 2;
 
printf("Lütfen 2 sayi girin");
scanf("%d%d", &ibo1, &ibo2);
printf("Girdiniz Sayilarin %d ve %d ortalamasi ise %d dir", ibo1, ibo2, ortalama);
getchar( );
return 0;
}



----------

Girilen sayinin icindeki 1 lerin kac adet oldugunu söyler.

Kod:


#include <stdio.h>
main()
{
int sayac = 0,i;
char sayi[15];
printf("\nGirilen Sayilar icinde Kac adet 1 Oldugunu Gösteren Program\n");
 
printf("Bir sayi girin..\n");
scanf("%s", sayi);
for(i = 0 ; i < (sizeof(sayi) / sizeof(char)) ; i++){
if (sayi[i] == '1')
sayac++;
printf("Girdiginiz Sayida %d Adet 1 Bulunmaktadir..\n", sayac);
getchar();
return 0;
}
}


insane 10 Mart 2010 17:57

Cevap: Örnek Kodlamalar Buraya..
 
Dosyaya yazma ;

Kod:

#include <stdio.h>
#include <stdlib.h>
 
main(){
 
  FILE *dosya;
 
  dosya = fopen( "d.txt", "w" );
 
  if( dosya == NULL ){
 
    printf("\ndosya acilamiyor");
    exit(1);
 
  }
 
  fputs( "deneme", dosya );
  fclose( dosya );
 
 
}

Bilgisayar model ve fiyatlarını bir diziye giren fiyat ve markaya göre arama ve listeleme yapan bir program yazın;

Kod:

#include<iostream.h>
#include<conio.h>
#include<string.h>
 
char marka [20][25];
float fiyat [20];
int i; N=20; int secim=0;
 
void verigirisi ( )
{
    for (i=0; i<N; i++)
    {
cout<<”marka ismi girin:”<<endl;
cin>>marka[i];
cout<<”Fiyat giriniz:”<<endl;
cin>>fiyat[i];
}
 
getch ( );
}
 
void markaara ( )
{
char aranan [25];
cout<<”Aranan markayı girin:”<<endl;
cin>>aranan;
for (i=0; i<N; i++)
 
if (strcmp (aranan,marka[i])==0)
{
cout<<marka[i]<<”-“<<fiyat[i]<<endl;
}
getch ( );
}
 
void fiyatara ( )
{
float aranan;
cout<<”Aranan fiyatı gir”<<endl;
cin>>aranan;
for (i=0; i<N; i++)
{
cout<<”Aradığınız fiyattaki marka:”<<marka[i]<<” “<<”fiyatı=”<<fiyat[i]<<endl;
}
}
getch ( );
}

Belli bir sayıya kadar olan asal sayıları bulmak;

Kod:

#include <stdio.h>
 
int main ()

        int a, b, c, d;
 
        printf (" Bir sayi giriniz : ");
        scanf  (" %d", &a);
 
        // Buradaki b, asal olup olmadığı araştırılacak olan sayıdır.
        for (b = 2; b < a; b ++)
        {
          d = 1;
              for (c = 2; c < b; c ++)
              {
                  // Sayı 2'den başlanarak kendisine kadar olan tüm tamsayılara
                  // sırayla bölünüyor. Tam bölen bir sayıya raslandığında
                  // sayının asal sayı olmadığı anlaşılıyor ve bir sonraki
                  // sayıyı denemek için döngü kesiliyor. Bu arada, bu sayının
                  // asal olamadığını anlamatmak için d'nin değeri 0 yapılıyor.
 
                  if (b % c == 0)
                  {
                    d = 0;
 
                    break;
                  }
          }
 
          // Burada iki ihtimal vardır. d == 0 ya da d == 1.
          // b'nin asal olmadığı anlaşıldığında d'nin değeri 0 yapılmıştı.
          // Aksi takdirde d'nin değeri bir kalır ve bu bize sayının asal
          // olduğunu anlatır.
 
          if (d == 1) printf (" %d \n", b );
 
          // Dögü bir sonraki sayının asal olup olmadığını anlamak için
          // tekrar dönecektir. Bu nedenle d'nin değeri döngünün başında
          // tekrar 1 yapılıyor.
        }
 
        return 0;
}

skor.txt dosyasina maç tarihi skorunu golleri kayit yapan yenileyen silen sorgulama yapabilen bir program! ;

Kod:

#include  <iostream.h>
#include  <conio.h>
#include  <fstream.h>
#include <iomanip.h>
 
 
int gun,ay,yil,biz,onlar,kontrol=0;
char saha;
 
void kayit()
{
int kayitSayisi,i;
cout<<"dosyaya kac kayit yapilacak ?"<<endl;
 cin>>kayitSayisi;
ofstream futbol;
futbol.open("skor.txt",ios::out);
for(i=0;i<kayitSayisi; i++)
{
cout<< " verileri giriniz ?"<<endl;
cin>>gun>>ay>>yil>>saha>>biz>>onlar;
futbol << gun<<setw(3)<<setw(3)<<ay<<setw(3)<<yil<<setw(3)<<saha<<setw(3)<<biz<<setw(3)
      <<onlar<<setw(3)<<endl;
}
futbol.close();
getch();
}
 
 
 
void kayitIlave()
{
int ilaveKayit,i;
cout<<"dosyaya kac kayit ilave edilecek ?"<<endl;
 cin>>ilaveKayit;
ofstream futbol;
futbol.open("skor.txt",ios::app);
for(i=0;i<ilaveKayit; i++)
{
cout<< " verileri giriniz ?"<<endl;
cin>>gun>>ay>>yil>>saha>>biz>>onlar;
futbol << gun<<ay<<yil<<saha<<biz<<onlar<<endl;
}
futbol.close();
getch();
}
 
void liste()
{
clrscr();
ifstream futbol;
futbol.open("skor.txt",ios::in);
while(futbol>>gun>>ay>>yil>>saha>>biz>>onlar)
{
cout<< gun<<ay<<yil<<saha<<biz<<onlar<<endl;
cout<endl;
 }
futbol.close();
getch();
}
 
void silme()
{
int silinecekYil;
clrscr();
cout<<"silinecek yil giriniz "<<endl;
 cin>>silinecekYil;
ifstream futbol;
futbol.open("skor.txt",ios::in);
ofstream gecici;
gecici.open("gecici.txt",ios::out);
while(futbol>>gun>>ay>>yil>>saha>>biz>>onlar)
{
if(silinecekYil!=yil)
{
 gecici << gun<<ay<<yil<<saha<<biz<<onlar<<endl;
 }
 }
 
 
futbol.close();
gecici.close();
 
  // copy temp to milan
  ifstream f1("gecici.txt");
  ofstream f2("skor.txt");
  f2<<f1.rdbuf();
 
}
 
 
void sorgu()
{int yilAra;
cout<<"hangi yila ait kayitlari araniyor ?"<<endl;
 cin>>yilAra;
ifstream futbol;
futbol.open("skor.txt",ios::in);
while(futbol>>gun>>ay>>yil>>saha>>biz>>onlar )
{
if(yilAra==yil)
cout<<  gun<<ay<<yil<<saha<<biz<<onlar<<endl;
}
futbol.close();
getch();
}
 
 
void menu()
{
int secim;
clrscr();
while(kontrol==0)
{
cout<<"[1] - Kayit " <<endl;
 cout<<"[2] - Kayit Ilave " <<endl;
  cout<<"[3] - Silme " <<endl;
  cout<<"[4] - Liste " <<endl;
    cout<<"[5] - sorgu " <<endl;
    cout<<"[6] - Cikis " <<endl;
      cout<<"Seciminiz:"<<endl;
      cin>>secim;
if(secim==1) kayit();
if(secim==2) kayitIlave();
if(secim==3) silme();
if(secim==4) liste();
if(secim==5) sorgu();
if(secim==6) kontrol=1;
else menu();
}
}
void main()
{
menu();
}


toXic 10 Mart 2010 19:34

Cevap: Örnek Kodlamalar Buraya..
 
Girilen Kelimelerin Kaç adet oldugunu söyler.


Kod:

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
main() {
int i,kelime_sayisi,uzunluk;
char cumle[50]; 
printf("lutfen arasinda tek bosluk olacak sekilde cumleyi giriniz:");
gets(cumle);  // katari aliyoruz
uzunluk=strlen(cumle); // ozel fonksiyon yardimi ile cumlenin uzunlugunu buluyoruz
kelime_sayisi=1;
  for(i=0; i<uzunluk; i++) {  // dongu cumle uzunlugu kadar donuyor
      if (cumle[i]==' ')  {      // bosluk karekteri geldiginde kelime sayisi 1 artiyor
        kelime_sayisi++; }     
          }
printf("kelime sayisi=%d",kelime_sayisi);
getch


Fonzerelli 08 Kasım 2010 13:58

Cevap: Örnek Kodlamalar Buraya..
 
Klasik Öğrenci Kayıt Sistemi
C++ dersini aldığımda verilmiş bir proje idi. Bilg. Mühd. öğrencilerine genellikle verilen fix projelerden biridir.

Alıntı:

project2.h
Kod:

#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
using namespace std;
class StudentList;

class StudentList
{
private:
    struct node
    {
        int StudentId;
        string StudentSurname;
        string StudentName;
        string Department;
        node *IdNext;
        node *SurnameNext;
    };
   
public:
    StudentList();
    ~StudentList();
    void add(node n);
    void pSurname(); //List w.r.t Surname
    void pId(); //List w.r.t ID
    bool del(int id);
    friend void createStudentList(string fileName,StudentList&);
    node *First,*FirstSurname;
    friend void editStudentList(StudentList & listName);   

};
string CutPart(int First,int last,string line);
string _ToUpper(string s);

Alıntı:

project2.cpp
Kod:


#include "project2.h"
#define sizeOfLine 1000
#include <algorithm>
#include <sstream>
#define PrintWrtSurname "ps"
#define PrintWrtId "pi"
#define AddStudent "i"
#define DeleteStudent "d"
#define Quit "q"

StudentList::StudentList()
{
    First = NULL;
    FirstSurname = NULL;
}
StudentList::~StudentList()
{
    node *temp,*q;
    if ( First==NULL)
        return;
    temp = First;
    if (temp->IdNext == First)
    {
        delete temp;
        return;
    }
    while ( temp->IdNext != First)
    {
        q= temp;
        temp = temp->IdNext;
        delete q;
    }
    delete temp;
}

void editStudentList(StudentList &List)
{
    string command;

    cout << "Welcome to Student Registration System " << endl;
    for(;;){
    cout << "Enter a command: ";
    cin >> command;
    if(command == PrintWrtSurname){     
        List.pSurname();
        cout << "With respect to surname" << endl;
    }
    else if(command == PrintWrtId){
        List.pId();
        cout << "With respect to id" << endl;}
    else if (command == Quit){
        break;
        cout << "DONE" << endl;
        return;
    }
    else if (command ==AddStudent){
        string t;
        int num;
        StudentList::node temp;
        cout << "Enter idno:";
        cin >> t;
       
        temp.StudentId = atoi(t.c_str());
        cout << "Enter Surname:";
        cin >> t;

        temp.StudentSurname = _ToUpper(t);
        cout <<"Enter Name:";
        cin >> t;
       
        temp.StudentName = _ToUpper(t);
        cout << "Enter Department:";
        cin >> t;
       
        temp.Department = _ToUpper(t);
        List.add(temp);
    }
    else if (command == DeleteStudent){
        unsigned int num;
        StudentList::node temp;
        cout << "Enter idno:";
        cin >> num;       
        List.del(num);
    }
    else cout << "No Command:" << command << endl;
    }
}
string _ToUpper(string str)
{
    for (int i = 0; i < str.length(); i++)

    {
    str[i]=toupper(str[i]);
    }
    return str;
}

void StudentList::add(node n)
{
    node *temp,*t,*k;
    t = new node;
    t->StudentId = n.StudentId;
    t->StudentName = n.StudentName;
    t->StudentSurname =n.StudentSurname;
    t->Department = n.Department;
    if ( First == NULL)
    {           
        t->IdNext = t;
        t->SurnameNext = t;
        First = t;
        FirstSurname = t;
        return;   
    }
    for (  k= First; k->IdNext !=First; k= k->IdNext)
    {
        if (k->StudentId == t->StudentId)
        {
            cout << "StudentID is unique";
            return;
        }
    }
    if ( k->StudentId == t->StudentId) {
        cout << "StudentID is unique";
        return;
    }
    // In the List, there is one element
    if (First->IdNext == First)
    {
        First->IdNext = t;
        t->IdNext = First;
        if (First->StudentId > t->StudentId){
            First = t;
        }
        // Changing Surname
        FirstSurname->SurnameNext = t;
        t->SurnameNext = FirstSurname;
        if (FirstSurname->StudentSurname > t->StudentSurname){
            FirstSurname = t;
        }       
       
    }
    else
    {
        temp = FirstSurname;
        // Begining of the Surname List, there may be add new node
        if (t->StudentSurname < FirstSurname->StudentSurname) {
            t->SurnameNext = FirstSurname;
            // Last Node
            while ( temp->SurnameNext != FirstSurname) { temp= temp->SurnameNext;}
            temp->SurnameNext = t;
            t->SurnameNext = FirstSurname;
            FirstSurname = t;
        }
        else {
            while ( temp->SurnameNext != FirstSurname) {
                if ((temp->SurnameNext)->StudentSurname > t->StudentSurname) {
                    t->SurnameNext = (temp->SurnameNext);
                    temp->SurnameNext = t;
                    break;
                }
                temp = temp->SurnameNext;
            }
            // At the end of  the list, there may be added
            if ( temp->SurnameNext == FirstSurname) {
                temp->SurnameNext = t;
                t->SurnameNext = FirstSurname;
            }
        }
        temp = First;
        //If new node is added begining of the ID Number List
        if (t->StudentId < First->StudentId){
            // Last of List
            while ( temp->IdNext != First){temp=temp->IdNext;}
            temp->IdNext = t;
            t->IdNext = First;
            First = t;
           
        }
        // Added element to the List
        else
        {
            while (temp->IdNext != First){
                if ( (temp->IdNext)->StudentId > t->StudentId){
                    t->IdNext = (temp->IdNext);
                    temp->IdNext = t;
                    break;
                }
                temp= temp->IdNext;
            }
                if( temp->IdNext ==First){
                    temp->IdNext = t;
                    t->IdNext = First;
            }
        }
       
       
    }
}
bool StudentList::del(int id)
{
    node *temp,*i, *tempSur, *j,*lastSurname;
    if ( First== NULL){
        cout << "Empty List";
        return false;
    }
    else if ( First->IdNext == First)
    {
        if(First->StudentId == id){
        delete First;
        First = NULL;
        FirstSurname =NULL;
        return true;
        }
        return false;
    }
    else {
        temp = First;
        i= First;
        j= FirstSurname;
        while ( temp->StudentId != id) { temp = temp->IdNext;}
                while ( i->IdNext != temp){ i= i->IdNext;}
        // i is a node
        i->IdNext = temp->IdNext;
        if ( temp == First) {First = temp->IdNext;}

        // Next Surname
                while (j->SurnameNext != temp) {j = j->SurnameNext;}
        // j points to a node in Surname List
        j->SurnameNext = temp->SurnameNext;
        if ( temp == FirstSurname ) {FirstSurname = temp->SurnameNext;}
        delete temp;

    }
}

void StudentList::pId()
{
    node *temp;
    temp= First;
    if(First==NULL)
    {
        cout << "Empty List";
        return;
    }
    else if ( temp->IdNext == First){
        cout << First->StudentId <<", "<<First->StudentName<<", "<<
                First->StudentSurname<< ", "<< First->Department;
        return;
    }
    else {
        while (temp->IdNext != First){
       
        cout << temp->StudentId <<", "<<temp->StudentName<<", "<<
                temp->StudentSurname<< ", "<< temp->Department<<endl;
        temp = temp->IdNext;
        }
        cout << temp->StudentId <<", "<<temp->StudentName<<", "<<
                temp->StudentSurname<< ", "<< temp->Department<<endl;
    }

}
void StudentList::pSurname()
{
    node *temp;
    temp= FirstSurname;
    if(FirstSurname==NULL)
    {
        cout << "The List is empty";
        return;
    }
    else if ( temp->SurnameNext == FirstSurname)
    {
        cout << FirstSurname->StudentSurname <<", "<<FirstSurname->StudentName<<", "<<
                FirstSurname->StudentId<< ", "<< FirstSurname->Department;
        return;
    }
    else
    {
        while (temp->SurnameNext != FirstSurname)
        {
       
        cout << temp->StudentSurname <<", "<<temp->StudentName<<", "<<
                temp->StudentId  << ", "<< temp->Department<<endl;
        temp = temp->SurnameNext;
        }
        cout << temp->StudentSurname <<", "<<temp->StudentName<<", "<<
                temp->StudentId<< ", "<< temp->Department<<endl;
    }
   
}
void createStudentList(string fileName,StudentList &List){
    char line[500];
    int pivot1,pivot2,count=1,idNum,recordNum=0;
    string temp,aline,name,surname,department;
    ifstream ListFile (fileName.c_str());
    // End of the Line
    while (! ListFile.eof() )
    {
        recordNum++;
        ListFile.getline (line,500);
        aline=line;
        pivot1=pivot2=0;
        count=1;
        // A Line
        for(unsigned int i=0;i<(aline.length());i++)
        {
            if(line[i]==','&& count==1)
            {
                pivot2=i;
                temp=CutPart(pivot1,pivot2,aline);
                count++;
                pivot1=i;
                idNum= atoi(temp.c_str());
               
            }
            else if(line[i]==',' && count==2)
            {
                pivot2=i;
                temp=CutPart(pivot1+1,pivot2,aline);
                count++;
                pivot1=i;
                name= temp;
            }
            else if(line[i]==',' && count==3)
            {
                pivot2=i;
                temp=CutPart(pivot1+1,pivot2,aline);
                count++;
                pivot1=i;
                surname= temp;
                pivot2=aline.length();
                temp=CutPart(pivot1+1,pivot2,aline);
                department=temp;
            }
        }
       
        if(count!=4)
        {
            cout <<"Invalid record in file at "<<recordNum<<"th(nd) row";
        }
        else
        {
            StudentList::node temp;
            temp.StudentId = idNum;
            temp.StudentName = name;
            temp.StudentSurname = surname;
            temp.Department = department;
            List.add(temp);
           
        }
       
    }
    ListFile.close();
}
string& trim(string &str)
{
    int i,j,start,end;

    //left trim
    for (i=0; (str[i]!=0 && str[i]<=32); )
        i++;
    start=i;

    //right trim
    for(i=0,j=0; str[i]!=0; i++)
        j = ((str[i]<=32)? j+1 : 0);
    end=i-j;
    str = str.substr(start,end-start);
    return str;
}
string& ltrim(string &str)
{
    int i,start;

    for (i=0; (str[i]!=0 && str[i]<=32); )
        i++;
    start=i;

    str = str.substr(start,str.length()-start);
    return str;
}
string& rtrim(string &str)
{
    int i,j,end;

    for(i=0,j=0; str[i]!=0; i++)
        j = ((str[i]<=32)? j+1 : 0);
    end=i-j;

    str = str.substr(0,end);
    return str;
}

string CutPart(int First,int last,string line)
{
    string temp;
    if(First<0 && First>line.length() && last>line.length() && First>last) return temp;
    for(int i=First;i<last;i++)
    {
        temp+= line[i];
    }
   
    return trim(temp);
   
}

Alıntı:

projectApp.cpp
Kod:

#include "project2.h"


int main()
{
   
    StudentList x;
    createStudentList("StudentList.txt",x);
    editStudentList(x);
    for(;;);
   
}

Alıntı:

command.cpp
Kod:

#include <iostream>
#include <string>
#include <stack>
#include <cctype>


using namespace std;

// The following defns should go into a .h file

#define PrintWrtSurname "ps"
#define PrintWrtId "pi"
#define AddStudent "i"
#define DeleteStudent "d"


void editStudentList(/* StudentList&*/)
{
    string command;

    cout << "Welcome to Student Registration System " << endl;

      for(;;){
      cout << "Enter a command: " << endl;
      cin >> command;

   

      if(command == PrintWrtSurname){
     
          // StudentList.printwrtSurname(); //
          cout << "List with respect to surname" << endl;}

      else if(command == PrintWrtId){
     
          // StudentList.printwrtId(); //
          cout << "List with respect to id" << endl;}

        else if (command == Quit){

                cout << "DONE " << endl;
                return;}
           
            else cout << "NO command: " << command << endl;
      }
}


int main(){

   

    editStudentList(/* cmpe160 */);
     
      return 0;
}

Alıntı:

StudentList.txt
Kod:

2007100307,    OGUZ    ,CEYLAN ,    cet
2005100700,    HASAN ,    COSKUN ,    tt
2008400024,DUYGU ,ALGAN ,    cmpe
2007101336, BETUL ,ARI ,cmpe
2006104564,ERCAN ,    AY ,    ee
2008400180,    ERVIN    ,DOMAZET,man
2004102743,AHMET FAIK,    BAK ,    cmpe
2007100631, EMRECAN ,BATI ,cee
2004104291,    TURGAY,    CAN ,    cmpe
2003104024,ERSIN,    AYDIN ,    ee
2006104624,AHMET ,    AYDIN ,    cmpe
2008400033,    HAKAN ,    DEMIR ,    man
2007100625,    ENES BAHADIR ,    DISBUDAK ,    man
2003104471,HASAN,ELMAS,man
2007102347,ESRA    ,ARSLAN ,cmpe
2005100736,REMZI    ,ASCI ,ee
2006102371,    BULUT    ,DEMIR ,    ptw


Firatt 16 Şubat 2013 16:31

Cevap: Örnek Kodlamalar Buraya..
 
Yeni BaşLayanLar için Sanırım En basit yapıLanLardan Biri Hesap makinası yapma Forumda Yapan ArkadaşLar varmıdır Bilmiyorum ama Başlayanlar için en basit Kod Dizini oLduğundan bende bundan başLadım . Yeni BaşLadığım için kendi Kendime yazdığım Cod Algoritmesı :))) Hesap Makinası

Alıntı:

#include<stdio.h>
int toplama(s1,s2);
int cikarma(s1,s2);
int bolme (s1,s2);
int carpma (s1,s2);
main()
{
int s1,s2,st;
char i;
printf("HESAP MAKINASI S.2.0\n");
printf("Islemi yaziniz Lütfen:\n");
scanf("%d%c%d",&s1,&i,&s2);
switch(i)
{
case '+':toplama(s1,s2);
break;
case '-':cikarma(s1,s2);
break;
case '/':bolme(s1,s2);
break;
case '*':carpma(s1,s2);
break;
default :printf("Yanlis islem Yaptınız\n");
}
system ("PAUSE");
return 0;
}

toplama(s1,s2)
{
printf("Toplama isleminin sonucu :%d\n",s1+s2);
}

cikarma(s1,s2)
{
printf("Cikarma isleminin sonucu
:%d\n",s1-s2);
}
bolme(s1,s2)
{
printf("Bolme isleminin sonucu
:%d\n",s1/s2);
}
carpma(s1,s2)
{
printf("Carpma isleminin sonucu
:%d\n",s1*s2);
}


Entrance 03 Ocak 2016 11:50

Cevap: Örnek Kodlamalar Buraya..
 
C ile küçük bir hesap makinası örneğide benden olsun.)

Son zamanlarda Dev C + + programını kullanarak bazı pratikler yapıyorum, umarım işinize yarar.)

Kod:


#include <stdio.h>

void Menu_goster();
void Toplama();
void Carpma();
void Cikarma();
void Bolme();

int main()
{
int islem;
Menu_goster();

basaal :printf("Yapmak istediginiz islemi seciniz..\n"); scanf("%d",&islem);
    switch(islem)
    {
    case 1:
    Toplama();
    break;
    case 2:
    Carpma();
    break;
    case 3:
    Cikarma();
    break;
    case 4:
    Bolme();
    break;
    default :
    printf("*** HATA! 1-4 arasinda islem seciniz..\n");
    goto basaal;
    }
 
}

void Menu_goster()
{
    printf("***Hesap Makinasina Hos gediniz.. ***\n");
    printf("Toplama islemi icin 1 :\n");
    printf("Carpma islemi icin  2 :\n");
    printf("Cikarma islemi icin 3 :\n");
    printf("Bolme islemi icin  4 :\n");
}

void Toplama()
{
    int bir,iki,sonucu;
    printf("2 sayi giriniz :"); scanf("%d%d",&bir,&iki);
    sonucu=bir+iki;
    printf("Toplama Sonucu : %d",sonucu);
}
void Carpma()
{
    int bir,iki,sonucu;
    printf("2 sayi giriniz :"); scanf("%d%d",&bir,&iki);
    sonucu=bir*iki;
    printf("Carpma Sonucu : %d",sonucu);
}
void Cikarma()
{
    int bir,iki,sonucu;
    printf("2 sayi giriniz :"); scanf("%d%d",&bir,&iki);
    sonucu=bir-iki;
    printf("Cikarma Sonucu : %d",sonucu);
}
void Bolme()
{
    float bir,iki,sonucu;
    printf("2 sayi giriniz :"); scanf("%f%f",&bir,&iki);
    sonucu=bir/iki;
    printf("Bolme Sonucu : %.2f",sonucu);
}

İyi forumlar.. ^^*


Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 15:36.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2025 IRCForumlari.Net Sparhawk