Program Kontrol Deyimleri Cevapları

1. Faktöriyel Hesabı


#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int sayi,fakt=1,i ;
cout<<"sayi giriniz"<<endl;
cin >>sayi;
i=sayi;
/*  for(sayi;sayi>0;sayi--)
fakt=fakt*sayi; */
while(sayi >0)
fakt=fakt*sayi--;
cout<<i <<" sayısinin fakt: " <<fakt<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}

&nbsp;</blockquote>
<span style="color: #ffffff; font-size: small;">2. Fonksiyon</span>
<blockquote>&nbsp;

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

using namespace std;

int main(int argc, char *argv[])
{
float x=0, f;

for(x=0; x<=5.0; x+=0.2)
{
f = pow(x,3) + 5*pow(x,2) + 4*x - 3;
cout << "f(" << x << "): " << f << endl;

}
system("PAUSE");
return EXIT_SUCCESS;
}

&nbsp;</blockquote>
<span style="font-size: small;">3. Finacci Serisi (1,2,3,5,8,13,21……..)</span>
<blockquote>#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int kucuk=1,buyuk=2, toplam=0;
while(buyuk+kucuk<2000)
{
toplam=kucuk+buyuk;
kucuk=buyuk;
buyuk=toplam;
cout<<toplam<<" ";
}
system("PAUSE");
return EXIT_SUCCESS;
}

&nbsp;</blockquote>
<span style="color: #ffffff; font-size: small;">4. Armstrong Sayıları ( abc = a^3 + b^3 + c^3)</span>
<blockquote>#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;

int main(int argc, char *argv[])
{
int a,b,c,abc=100;
while (abc<1000)
{
a=abc/100;
b=(abc%100)/10;
c=abc%10;
if (pow(a,3)+pow(b,3)+pow(c,3)==abc)
cout<< abc << " sayisinin basamaklari "<<a<< " , "<<b<< " , "<< c<< endl;
abc++;
}
system("PAUSE");
return EXIT_SUCCESS;
}

&nbsp;</blockquote>
<blockquote>#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;

int main(int argc, char *argv[])
{
int a,b,c,d;

for(a=1; a<=9; a++)
for(b=0; b<=9; b++)
for(c=0; c<=9; c++)
for(d=0; d<=9 ; d++)
if(pow(a,4)+ pow(b,4)+ pow(c,4)== 1000*a + 100*b +10*c +d)
cout << a << b << c << d << " " ;
system("PAUSE");
return EXIT_SUCCESS;
}

Yorum Yapın

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d blogcu bunu beğendi: