Page 1

0 PHP

0C 0 C ++


PHP ÖRNEKLERİ


ECHO KOMUTU ‘ <?php echo "Merhaba Dünya"; ?>


0 <?php

echo "<h1>Merhaba D端nya</h1>"; 0 ?>


<?php $degisken = 20 echo "$deÄ&#x;iĹ&#x;ken = degisken <br>"; echo "\$degisken<br> \n"; echo '\n$degisken<br>';

?>


<?php $a = 32; $b = "BOTE"; $c = "5.6"; echo "$a$b"; echo "<br>"; echo $b; echo "<br>"; echo '$b'; echo "<br>"; echo "BĂślĂźm : $b vize : $a <br> \n"; echo $c.' &nbsp;&nbsp;&nbsp;&nbsp;'.$a; echo $c."\t".$a;

?>


<?php $t = "10"; echo "'Benim $t liram var.' dedi.<br>\n"; echo '"Benim $t liram var." dedi.<br>\n; echo "ben aşağıdayım";

?>


<?php $w = 5; $z= 7; echo $w*$z; echo "<br> \n"; echo $w."*".$z. '='. $w*$z; echo "<br> \n"; echo "$w * $z = $w*$z<br>\n"; echo "$w * $z = ".$w*$z." ve "."$z* $w = ".$z*$w; echo "<br> \n"; echo "$w * $z +1= ".($w*$z+1)." olur";

?>


<?php $z = 3.14; $depo = sprintf("Pi'nin değeri : %f <br>",$z); echo $depo;//depo değişkeninin içeriğini yazar.

?>


<?php for($i=0; $i<10; $i++) { echo "sayi : $i <br>\n"; }

?>


<?php echo "<table border = '1'>\n"; for($satir=1; $satir <6; $satir++) { echo "<tr> \n"; for($sutun = 1; $sutun<6; $sutun++) { echo "\t<td> $satir x $sutun = ".($satir*$sutun)."</td> \n";

echo "</tr>\n"; } echo "</table>\n";

?>


<?php echo "<table border = '1'>\n"; $hucre = 1; for($satir=1; $satir <6; $satir++) { echo "<tr> \n"; for($sutun = 1; $sutun<6; $sutun++) { echo "\t<td>".$hucre++ ."</td> \n"; } echo "</tr>\n"; } echo "</table>\n";

?>


<?php echo "<table border='1'> \n"; for($satir = 0; $satir<16; $satir++) { echo "<tr> \n"; //sat覺r a癟覺l覺yo for($hucre = 0; $hucre<16; $hucre++) { $renk = sprintf("%02x",255-($satir*16+$hucre)); echo "<td bgcolor='#".$renk.$renk.$renk."'>".$renk." </td>\n"; } echo "</tr> \n"; } echo "</table>";

?>


<?php echo "<table border='1'> \n"; for($satir = 1; $satir<11; $satir++) { echo "<tr> \n"; for($hucre = 1; $hucre<11; $hucre++) { printf ("<td> %2d x %2d = %3d </td>\n",$satir,$hucre , $hucre*$satir); } echo "</tr> \n"; } echo "</table>";

?>


<?php $sayi = rand(1,20); if ($sayi<10)//sayı ondan küçükse $mesaj = "Ondan küçük"; else if ($sayi>10)//üretilen sayı 10 dan büyükse $mesaj = "Ondan büyük"; else $mesaj = "Tam On";

echo $sayi." ->".$mesaj;

?>


<?php echo "<table border = '1'>\n"; for($satir=1; $satir <10; $satir++) { echo "<tr> \n";//satır açılıyo for($sutun = 1; $sutun<10; $sutun++) { $r = rand(0,255); $g = rand(0,255); $b = rand(0,255); printf("\t<td bgcolor='#%02x%02x%02x'> .... </td> \n",$r,$g,$b); } echo "</tr>\n"; } echo "</table>\n";

?>


<?php echo "<table border = '0' padding='0' cellspacing='0' width='100%'>\n; for($satir=1; $satir <10; $satir++){ echo "<tr> \n"; for($sutun = 1; $sutun<10; $sutun++) { $renk = rand(0,16581385);// printf("\t<td bgcolor='#%06x' width='10%%'> &nbsp; </td> \n",$renk); } echo "</tr>\n"; } echo "</table>\n";

?>


<?php $dizi = array("ahmet","mehmet","kola","dondurma", "baklava","börek"); echo $dizi[3]; echo "<hr>"; for($i = 0; $i<6; $i++) { echo $dizi[$i]." - "; } echo "<hr>";//düz çizgi çeker foreach ($dizi as $eleman) { echo $eleman." -> "; } echo "<hr>"; foreach ($dizi as $anahtar=>$eleman) { echo $anahtar.":".$eleman." -> "; }

?>


<table border="1"> <?php for($satir=1; $satir<11; $satir++) { echo "<tr> \n"; for($sutun=1; $sutun<11; $sutun++) { echo "<td> ".(100- (($satir-1) * 10 + $sutun))."</td>\n"; } echo "</tr>\n"; }

?> </table>


<table border="1">; <?php $sayac = 1; for($satir=1; $satir<10; $satir++) { echo "<tr> \n"; for($sutun=1; $sutun<10; $sutun++) { if ($sayac % 2 == 0 ) $renk = "#000000"; else $renk = "#ffffff"; echo "<td bgcolor = '$renk'> $sayac </td>\n" } echo "</tr>\n"; } ?> </table>


<table border="1"> <?php for($satir=1; $satir<10; $satir++) { echo "<tr> \n"; for($sutun=1; $sutun<10; $sutun++) { if (($sutun+$satir) % 2 == 0 ) $renk = "#000000"; else $renk = "#ffffff"; if ($sutun == 1) echo "<td bgcolor = 'lightblue'>".(9$satir)."</td>\n"; if ($satir == 9) echo "<td bgcolor = 'lightblue'>".chr(64+$sutun)."</td>\n"; else echo "<td bgcolor = '$renk'>". ($sutun+$satir)." </td>\n"; } echo "</tr>\n"; } ?> </table>


<form action="" method="POST"> Say覺 1:<input type="text" name="s1"> <br> Say覺 2: <input type="text" name="s2"> <br> <input type="submit" value="Topla" name="gonder"> </form> <br> <?php if(isset($_POST['gonder'])) echo "$_POST[s1] + $_POST[s2] = ".($_POST[s1]+$_POST[s2]); ?>


<form action="" method="POST"> Say覺 1:<input type="text" name="s1"> <br> <input type="submit" value="Fakt繹riyel" name="gonder"> </form> <br> <?php if(isset($_POST['gonder']) && $_POST['s1']>1 && $_POST['s1']<100) { $s = $_POST['s1']; $f = 1; for($i = $s;$i>1; $i--) $f *= $i; echo $s."! = $f"; } ?>


0 C ÖRNEKLERİ


#include<stdio.h> main() { int sayi=5,sayi2=2; char harf='A',harf2='b'; float ort; ort=(sayi+sayi2)/2; printf("sayinin degeri=%d\n",sayi); printf("sayinin degeri=%d ,sayi2 nin degeri=%d",sayi,sayi2); printf("\n%d ve %d sayilarinin ortalamasi=%f\n",sayi,sayi2,ort); printf("harf=%c dir veeeeeee harf2 de =%c dir",harf,harf2); }


0 #include <stdio.h>

main() { int v,f; float ort=1.0; printf("*******HOSGELDINIZ********\n"); printf("lutfen vizenizi giriniz"); scanf("%d",&v); printf("lutfen finalinizi giriniz"); scanf("%d",&f); ort=(v*0.4+f*0.6); printf("vizeniz=%d\tfinaliniz=%d\tortalamaniz=%f\n",v,f,or t); }


0 #include <stdio.h>

main() { int v,f; float ort; printf("lutfen vize notunu giriniz"); scanf("%d",&v); printf("lutfen final notunu giriniz"); scanf("%d",&f); ort=v*0.4+f*0.6; if(f>=60 && ort>=60) printf("%f ortalamasi ile GECTINIZ",ort); else printf("%f ortalamasi ile KALDINIZ",ort); }


0 #include<stdio.h>

main() { int sayi1,sayi2,secim; float sonuc; printf("1-toplama \n"); printf("2-cikarma \n"); printf("3-carpma \n"); printf("4-bolme \n"); printf("seciminiz= ");scanf("%d",&secim); printf("birinci sayiyi giriniz= ");scanf("%d",&sayi1); printf("ikinci sayiyi giriniz= ");scanf("%d",&sayi2); if (secim==1) sonuc=sayi1+sayi2; else if(secim==2) sonuc=sayi1-sayi2; else if(secim==3) sonuc=sayi1*sayi2; else if(secim==4) sonuc=sayi1/sayi2; else printf("hatali giris"); printf("islemin sonucu= %f dir",sonuc);

}


0 #include <stdio.h>

main() { int x,sonuc; printf("x degeri giriniz:"); scanf("%d",&x); if (x>0 && x<2) sonuc=(x*x)/(x+3); else if (x>=2 && x<4) sonuc=x*x*x; else if(x>=4) sonuc=x; printf("sonuc sudur=%d",sonuc);

}


0 #include <stdio.h> 0 main()

{ int sayi; printf("lutfen 1- 5 arasinda sayi giriniz\n"); scanf("%d",&sayi); switch (sayi) { case 1: printf("girdiginiz sayi birdir");break; case 2: printf("girdiginiz sayi ikidir");break; case 3: printf("girdiginiz sayi uctur");break; case 4: printf("girdiginiz sayi dorttur");break; case 5: printf("girdiginiz sayi bestir");break; default : printf("yanlis sayi girdiniz"); } 0}


0 #include<stdio.h> 0 main()

{

char harf; printf("lutfen harf giriniz");scanf("%c",&harf); switch (harf) { case 'A': case 'a':printf("sesli harf");break; case 'E': case 'e':printf("sesli harf");break; case 'I': case 'i':printf("sesli harf");break; case 'U': case 'u':printf("sesli harf");break; case 'O': case 'o':printf("sesli harf");break; default :printf("sessiz harf");

} }


0 #include<stdio.h>

0 main()

{ int sayi,i; long sonuc=1; printf("faktoriyeli hesaplacak sayiyi giriniz\n");scanf("%d",&sayi); for(i=1;i<=sayi;i++) sonuc=sonuc*i; printf("%d faktoriyel =%d dir",sayi,sonuc); 0}


0 #include<stdio.h>

main() { int sayi,i=1; long sonuc=1; printf("sayiyi giriniz\n");scanf("%d",&sayi); while(i<=sayi){ sonuc*=i; i++; }; printf("%d faktoriyel= %d dir",sayi,sonuc); }


0 #include<stdio.h> 0 main()

{ int i; for(i=1;i<101;i++) { printf("BOTE\n"); } 0}


0 #include<stdio.h> 0 main()

{ int i; for(i=1;i<100;i++) { if(i%2==0) printf("%d\t",i); }

0}


0 #include<stdio.h>

#include<windows.h> void gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);

} main() { int i,j; for(i=5;i<50;i++) { gotoxy(i,10);printf("*"); gotoxy(i,15);printf("*"); } for(j=2;j<20;j++) {

gotoxy(5,j);printf("*"); gotoxy(50,j);printf("*"); }

}


0 #include<stdio.h>

main() { int i; for(i=0;i<256;i++) printf("%d -> %c\t",i,i);

}


0 #include <stdio.h>

void mesaj_1() { printf("merhaba "); } void mesaj_2() { mesaj_1(); printf("hosgeldiniz"); } void mesaj_3() { mesaj_2(); printf(" arkadaslar"); } main() { mesaj_3(); }


0 #include <stdio.h>

int usal(int taban,int kuvvet) { int sonuc=1,i; for(i=1;i<=kuvvet;i++) sonuc*=taban; return sonuc; } main() { int t,k,son=1; printf("lutfen taban ve kuvveti giriniz\n"); scanf("%d,%d",&t,&k); son=usal(t,k); printf("sonuc=%d",son); }


0 #include <stdio.h> 0 #include <conio.h>

main() { char cumle[100]; int a=0; puts("bir cumle giriniz"); gets(cumle); while(cumle[a]!='\0') // NULL //for(a=0;cumle[a]!=NULL;a++) a++; printf("grdiginiz cumle %d karakter uzunlugundadir",a); }


0 #include <stdio.h> 0 #include <conio.h>

main() { char depo[80],c; int i=0; while((c=getch())!='.') { depo[i++]=c; } depo[i]='\0'; puts(depo); }


0 #include <stdio.h> 0 #include <conio.h> 0 main()

{ int a=0,i; char cumle[100]; puts("bisiler yazin"); gets(cumle); while(cumle[a]!='\0') a++; for(i=a;i>=0;i--) printf("%c",cumle[i-1]); 0}


0 #include <stdio.h>

0 #include <conio.h>

main() { char metin[15]="dasdada"; printf("%s\n",metin); printf("ekrana birşey yazın...\n"); scanf("%s",metin); printf("%s\n",metin);

}


0 #include <stdio.h> 0 #include <conio.h>

main() { int i,j; char aile[4][15]={"fatma","osman","ali","hatice"}; char yedek_aile[4][15]; for(i=0;i<4;i++) { printf("%d. kisinin adini giriniz\t",i+1); scanf("%s",yedek_aile[i]); } for(j=0;j<4;j++) { printf("aile ailesinin %d.kisinin adi=%s\n",j+1,aile[j]); printf("yedek_aile ailesinin %d.kisinin adi=%s\n",j+1,yedek_aile[j]); }

}


0 #include <stdio.h> 0 #include <conio.h>

main() { int i,j; char aile[4][15]={"fatma","osman","ali","hatice"}; for(i=0;i<4;i++) //for(i=3;i>=0;i--) printf("%d.kisi=%s\n",i+1,aile[3-i]); }


0 C++ ÖRNEKLERİ


0 #include <iostream>

using namespace std; int main() { cout << "merhaba d端nya!" <<endl;

}


0 #include <iostream>

using namespace std; int main() { cout << "ali\nveli" << endl; cout << "huseyin" <<endl<< "sevgi " <<"siz girin"; int i; cin>>i; return 0;

}


0 #include <iostream> 0 using namespace std; 0 class Ogrenci{ 0 public: void set_vize(); void set_final(); int get_vize(); int get_final(); void yaz();

0

private: int vize; int final;

}; 0 void Ogrenci::set_vize() { cout<<"vize:"<<endl; cin>>vize; } 0 void Ogrenci::set_final() { cout<<"final:"<<endl; cin>>final; } DEVAMI DİĞER SAYFADA………..


int Ogrenci::get_vize() { return vize; } 0 int Ogrenci::get_final() { return final; } 0 void Ogrenci::yaz() { cout<<"ogrencinin:\n"<<endl; cout<<"vizesi....."<<get_vize()<<endl; cout<<"finali....."<<get_final()<<endl; cout<<"ortalamasi="<<(get_final()+get_vize())/2; } 0 int main() { Ogrenci ogr; ogr.set_vize(); ogr.set_final(); ogr.yaz(); return 0; }


0 #include <iostream> 0 #include "str.h" 0 using namespace std; 0 int main() 0 { 0 Str metin(20); 0 metin.harf_ekle('B'); 0 metin.harf_ekle('A'); 0 metin.harf_ekle('B'); 0 metin.harf_ekle('A'); 0 metin.yaz(); 0 int a; 0 cin>>a; 0 return 0; 0 }


0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

#include "str.h" using namespace std; Str::Str(int sinir) { //ctor uz=sinir; cout<<"hafizada ayrilan yer:"<<uz<<endl; p=(char *) malloc(uz); if(!p) { cout<<"yer alamadik"; exit(1); } else cout<<"yeri aldim\n"; *p='\0'; pos=0; }


0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Str::~Str() { //dtor cout<<"program bitiyor...\n"; free(p); } void Str::harf_ekle(char c) { p[pos]=c; pos++; p[pos]='\0'; // NULL } void Str::yaz() { cout<<p; }


0 #include <iostream> 0 using namespace std; 0 class A{ 0 public: 0

void setX(int x); private: int aX;

}; 0 void A::setX(int x)

{ aX= x; cout<<"A: "<<aX<<endl; } 0 class B:public A{ 0 public: void setY(int y); 0 private: int bY; };


0 void B::setY(int y)

{ bY = y; cout<<"B: "<<bY<<endl;

} 0 int main() { A nesne; nesne.setX(17); B mesne; mesne.setY(18); mesne.setX(29); return 0;

}


0 SON


nayimmengubeti  

projegelistirme2

Read more
Read more
Similar to
Popular now
Just for you