SlideShare a Scribd company logo
5..Ders : C Giriş / Çıkış
Bu derste, C programlamada I/O görevi gerçekleştirmek için iki
yerleşik işlev printf () ve scanf () üzerinde durulur. Ayrıca,
C de geçerli bir program yazmayı öğreneceksiniz.
C programlama, giriş ve çıkış görevlerini gerçekleştirmek için
çeşitli yerleşik kitaplık işlevlerine sahiptir.
Input Output (I/O) [(Giriş / Çıkış)] için yaygın olarak
kullanılan iki işlev printf () ve scanf () ‘dir.
Scanf () işlevi, standart girdiden (klavye) biçimlendirilmiş
girişi okur, printf () işlevi standart çıktıya (ekrana)
biçimlendirilmiş çıktı gönderir.
Örnek 1 : C çıkış (C Output)
#include <stdio.h> // Printf () fonksiyonunu çalıştırmak için
başlık dosyasını dahil ediyoruz
int main()
{
printf("C Programlama"); // geçerli içeriği
görüntülüyoruz
return 0;
}
Çıktısı :
C Programlama
Bu program nasıl çalışır?
Tüm geçerli C programları main () işlevini içermelidir. Kod
yürütme, main () fonksiyonunun başlangıcından başlar.
Printf (), formatlanmış çıktıyı ekrana göndermek için bir
kütüphane fonksiyonudur. Printf () fonksiyonu”stdio.h” başlık
dosyasında bildirilmiştir.
Burada, stdio.h bir başlık dosyasıdır (standart giriş çıkış
başlık dosyası) ve #include, gerektiğinde kodu başlık
dosyasından yapıştırmak için bir önişlemci yönergesidir.
Derleyici printf () fonksiyonuyla karşılaştığında ve stdio.h
başlık dosyasını bulamadığında, derleyici hatası gösterir.
return 0; programın “Çıkış durumu” dur. ( Exit status )
Örnek 2 : C Tamsayı Çıkışı (C Integer Output)
#include <stdio.h>
int main()
{
int testInteger = 5;
printf("Sayi= %d", testInteger);
return 0;
}
Çıktısı :
Sayi= 5
Printf () işlevinde tırnak içinde, “% d” (tam sayı için)
biçiminde bir dize var. Biçim dizgisi argümanla eşleşiyorsa
(bu durumda testInteger), ekranda görüntülenir.
Örnek 3 : C Tamsayı Giriş / Çıkış (C Integer
Input/Output)
#include <stdio.h>
int main()
{
int testInteger;
printf("bir tamsayı giriniz: ");
scanf("%d",&testInteger);
printf("Sayı = %d",testInteger);
return 0;
}
Çıktısı :
bir tamsayı giriniz: 4
Sayı = 4
Scanf () işlevi klavyeden biçimlendirilmiş girişi okur.
Kullanıcı bir tamsayı girdiğinde, testInteger değişkeninde
saklanır.
TestInteger öncesi ‘&’ işaretini not edin; & testInteger,
testInteger adresini alır ve değer bu adrese kaydedilir.
Örnek 4 : C Ondalıklı Sayı Giriş / Çıkış (C Floats
Input/Output)
#include <stdio.h>
int main()
{
float f;
printf("bir sayı giriniz: ");
scanf("%f",&f);
printf("girdiginiz deger= %f", f);
return 0;
}
Çıktısı :
bir sayı giriniz: 23.45
girdiginiz deger = 23.450000
“%f” format dizgisi, ondalıklı sayı durumunda formatlanmış
okuma ve görüntüleme için kullanılır.
Örnek 5 : C Karakteri Giriş / Çıkış (C Character I/O)
#include <stdio.h>
int main()
{
char chr;
printf("bir karakter girin: ");
scanf("%c",&chr);
printf("girdiginiz %c.",chr);
return 0;
}
Çıktısı :
bir karakter girin: g
girdiginiz g.
Karakter tipleri durumunda “%c” format dizgisi kullanılır.
Yukarıdaki programa bir karakter girildiğinde, karakterin
kendisi saklanmaz. Bunun yerine, sayısal bir değer ASCII
değeri saklanır.
Bu değeri “% c” metin biçimini kullanarak görüntülediğimizde,
girilen karakter görüntülenir.
Örnek 6 : C ASCII Kodu (C ASCII Code)
#include <stdio.h>
int main()
{
char chr;
printf("bir karakter giriniz: ");
scanf("%c",&chr);
// % C metin formatı kullanıldığında, karakter türlerinde
karakter görüntülenir
printf("girdiginiz karakter %c.n",chr);
// % D metin formatı kullanıldığında, karakter türlerinde
tam sayı görüntülenir.
printf("ASCII degeri : %c sayisal degeri ise %d.", chr,
chr);
return 0;
}
Çıktısı :
bir karakter giriniz: g
girdiginiz karakter g.
ASCII degeri : g sayisal degeri ise 103.
Bir karakterin ASCII kodunu biliyorsanız bir karakteri
görüntüleyebilirsiniz. Bu, aşağıdaki örnekle gösterilmiştir.
Örnek 7 : C ASCII Kodu (C ASCII Code)
#include <stdio.h>
int main()
{
int chr = 69;
printf("69 karakterinin ASCII değeri : %c.",chr);
return 0;
}
Çıktısı :
69 karakterinin ASCII değeri : E.
Örnek 8 : Ondalıklı ve Tam Sayıların Giriş / Çıkış
işlemleri (I/O of Floats and Integers)
#include <stdio.h>
int main()
{
int integer = 9876;
float decimal = 987.6543;
printf("4 basamaklı tamsayıyı noktadan sonra 6 basamak
yaz: %6dn", integer);
printf("4 basamaklı tamsayıyı noktadan sonra 3 basamak
yaz: %3dn", integer);
printf("Ondalıklı sayıyı noktadan sonra 2 basamak yaz:
%.2fn",decimal);
printf("Ondalıklı kısmı 0'a yuvarla: %.fn",987.6543);
printf("Ondalıklı sayıyı Üslü biçimde yaz:
%en",987.6543);
return 0;
}
Çıktısı :
4 basamaklı tamsayıyı noktadan sonra 6 basamak yaz: 9876
4 basamaklı tamsayıyı noktadan sonra 3 basamak yaz: 9876
Ondalıklı sayıyı noktadan sonra 2 basamak yaz: 987.65
Ondalıklı kısmı 0'a yuvarla: 988
Ondalıklı sayıyı Üslü biçimde yaz: 9.876543e+02

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

C giris-cikis-c-input-output

  • 1. 5..Ders : C Giriş / Çıkış Bu derste, C programlamada I/O görevi gerçekleştirmek için iki yerleşik işlev printf () ve scanf () üzerinde durulur. Ayrıca, C de geçerli bir program yazmayı öğreneceksiniz. C programlama, giriş ve çıkış görevlerini gerçekleştirmek için çeşitli yerleşik kitaplık işlevlerine sahiptir. Input Output (I/O) [(Giriş / Çıkış)] için yaygın olarak kullanılan iki işlev printf () ve scanf () ‘dir. Scanf () işlevi, standart girdiden (klavye) biçimlendirilmiş girişi okur, printf () işlevi standart çıktıya (ekrana) biçimlendirilmiş çıktı gönderir. Örnek 1 : C çıkış (C Output) #include <stdio.h> // Printf () fonksiyonunu çalıştırmak için başlık dosyasını dahil ediyoruz int main() { printf("C Programlama"); // geçerli içeriği görüntülüyoruz return 0; } Çıktısı : C Programlama
  • 2. Bu program nasıl çalışır? Tüm geçerli C programları main () işlevini içermelidir. Kod yürütme, main () fonksiyonunun başlangıcından başlar. Printf (), formatlanmış çıktıyı ekrana göndermek için bir kütüphane fonksiyonudur. Printf () fonksiyonu”stdio.h” başlık dosyasında bildirilmiştir. Burada, stdio.h bir başlık dosyasıdır (standart giriş çıkış başlık dosyası) ve #include, gerektiğinde kodu başlık dosyasından yapıştırmak için bir önişlemci yönergesidir. Derleyici printf () fonksiyonuyla karşılaştığında ve stdio.h başlık dosyasını bulamadığında, derleyici hatası gösterir. return 0; programın “Çıkış durumu” dur. ( Exit status ) Örnek 2 : C Tamsayı Çıkışı (C Integer Output) #include <stdio.h> int main() { int testInteger = 5; printf("Sayi= %d", testInteger); return 0; } Çıktısı : Sayi= 5 Printf () işlevinde tırnak içinde, “% d” (tam sayı için) biçiminde bir dize var. Biçim dizgisi argümanla eşleşiyorsa (bu durumda testInteger), ekranda görüntülenir.
  • 3. Örnek 3 : C Tamsayı Giriş / Çıkış (C Integer Input/Output) #include <stdio.h> int main() { int testInteger; printf("bir tamsayı giriniz: "); scanf("%d",&testInteger); printf("Sayı = %d",testInteger); return 0; } Çıktısı : bir tamsayı giriniz: 4 Sayı = 4 Scanf () işlevi klavyeden biçimlendirilmiş girişi okur. Kullanıcı bir tamsayı girdiğinde, testInteger değişkeninde saklanır. TestInteger öncesi ‘&’ işaretini not edin; & testInteger, testInteger adresini alır ve değer bu adrese kaydedilir. Örnek 4 : C Ondalıklı Sayı Giriş / Çıkış (C Floats Input/Output) #include <stdio.h> int main() { float f;
  • 4. printf("bir sayı giriniz: "); scanf("%f",&f); printf("girdiginiz deger= %f", f); return 0; } Çıktısı : bir sayı giriniz: 23.45 girdiginiz deger = 23.450000 “%f” format dizgisi, ondalıklı sayı durumunda formatlanmış okuma ve görüntüleme için kullanılır. Örnek 5 : C Karakteri Giriş / Çıkış (C Character I/O) #include <stdio.h> int main() { char chr; printf("bir karakter girin: "); scanf("%c",&chr); printf("girdiginiz %c.",chr); return 0; } Çıktısı : bir karakter girin: g girdiginiz g.
  • 5. Karakter tipleri durumunda “%c” format dizgisi kullanılır. Yukarıdaki programa bir karakter girildiğinde, karakterin kendisi saklanmaz. Bunun yerine, sayısal bir değer ASCII değeri saklanır. Bu değeri “% c” metin biçimini kullanarak görüntülediğimizde, girilen karakter görüntülenir. Örnek 6 : C ASCII Kodu (C ASCII Code) #include <stdio.h> int main() { char chr; printf("bir karakter giriniz: "); scanf("%c",&chr); // % C metin formatı kullanıldığında, karakter türlerinde karakter görüntülenir printf("girdiginiz karakter %c.n",chr); // % D metin formatı kullanıldığında, karakter türlerinde tam sayı görüntülenir. printf("ASCII degeri : %c sayisal degeri ise %d.", chr, chr); return 0; } Çıktısı : bir karakter giriniz: g girdiginiz karakter g.
  • 6. ASCII degeri : g sayisal degeri ise 103. Bir karakterin ASCII kodunu biliyorsanız bir karakteri görüntüleyebilirsiniz. Bu, aşağıdaki örnekle gösterilmiştir. Örnek 7 : C ASCII Kodu (C ASCII Code) #include <stdio.h> int main() { int chr = 69; printf("69 karakterinin ASCII değeri : %c.",chr); return 0; } Çıktısı : 69 karakterinin ASCII değeri : E. Örnek 8 : Ondalıklı ve Tam Sayıların Giriş / Çıkış işlemleri (I/O of Floats and Integers) #include <stdio.h> int main() { int integer = 9876; float decimal = 987.6543; printf("4 basamaklı tamsayıyı noktadan sonra 6 basamak yaz: %6dn", integer);
  • 7. printf("4 basamaklı tamsayıyı noktadan sonra 3 basamak yaz: %3dn", integer); printf("Ondalıklı sayıyı noktadan sonra 2 basamak yaz: %.2fn",decimal); printf("Ondalıklı kısmı 0'a yuvarla: %.fn",987.6543); printf("Ondalıklı sayıyı Üslü biçimde yaz: %en",987.6543); return 0; } Çıktısı : 4 basamaklı tamsayıyı noktadan sonra 6 basamak yaz: 9876 4 basamaklı tamsayıyı noktadan sonra 3 basamak yaz: 9876 Ondalıklı sayıyı noktadan sonra 2 basamak yaz: 987.65 Ondalıklı kısmı 0'a yuvarla: 988 Ondalıklı sayıyı Üslü biçimde yaz: 9.876543e+02