Jump to content

C++ Fonksiyon Kullanarak Işlem


şeytan67
 Share

Recommended Posts

Klavyeden  girilen  bir sayının karesını  fonksıyon kullanarak hesaplayan program  C++ lazım  arkadaşlar bana  kod yazmasını bilen  arkadaşlar yardımcı olabilirlermi benim fazla  bilgim olmadığı için yazamıyorum 

Edited by şeytan67
Link to comment
Share on other sites

Aslında pow ile de yapılabilir ama sana iki şekilde de gösterelim.

#include <iostream>
#include <math.h>

using namespace std;

int kareAl(int y)
{
   double sonuc;
   return sonuc = pow(y,2.0);
     
}
int main()
{
    int sayi,sayinin_karesi;    
    cout << "Bir sayi giriniz: " << endl;
    cin >> sayi;
    sayinin_karesi = kareAl(sayi);
    cout << "Sayinin karesi = " << sayinin_karesi << endl;
    
    return 0;
 
}

#include <iostream>

using namespace std;

int kareAl(int y)
{
  return y*y;    
}
int main()
{
    int sayi,sayinin_karesi;    
    cout << "Bir sayi giriniz: " << endl;
    cin >> sayi;
    sayinin_karesi = kareAl(sayi);
    cout << "Sayının karesi = " << sayinin_karesi << endl;    
    return 0;
 
}

Edited by SimpsoN_Bart
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...