C++ Girilen Sayının Faktöriyelini Alma

R

Rooster

only business
Super Moderator
Joined
Aug 10, 2019
Messages
3,215
Reaction score
4,728
Location
Milano
C++ ile kullanıcıdan sayıyı isteyen ve kullanıcıdan girdiği bu sayının faktöriyelini hesaplayarak ekranda gösteren örneğe ait kodlar.


Kodlarımızı incelediğimizde kullanıcıdan alınan sayının For Döngüsü içinde kullanılarak 11 den bu sayıya kadar sayıların çarpılarak sonuc değişkenine aktarıldığını görüyoruz.

Bunun haricinde örneğimizde Türkçe karakterlerin gösterilebilmesi için;

#include<locale.h>

Code:
#include<locale.h>
ve
Code:
setlocale(LC_ALL,"Turkish");
satırlarının eklendiğini belirtelim.


Code:
#include <iostream>
#include<locale.h>
 
using namespace std;
int main()
{
    setlocale(LC_ALL,"Turkish");
    int sayi, sonuc = 1, i;
    cout << "Sayıyı Girin : "; cin >> sayi;
    for (i = 1; i <= sayi; i++)
    {
        sonuc = i*sonuc;
    }
    cout << sayi << " sayısının faktoriyeli : " << sonuc;
}
 
SPAM IS FORBIDDEN!
  • SPAMMERS ARE BANNED FROM THE FORUM AND CANNOT USE ANY OF THE CHEATS
  • For example: thanks, thx, very good, asdqwe, working, ty and so on!
  • For example: Writing the same message over and over. thanks, thx and so on!
  • Copying and copying someone else's message is prohibited.
  • It is forbidden to send messages to increase the number of comments on threads that you have no knowledge of.
  • Write your own opinion when commenting!
  • If you see spam message, please let us know with the REPORT button!

Tema düzenleyici

Top Bottom