hoSSohbeT.com  Sohbet  forumlari

Anasayfa Bugünki Mesajlar Forumları Okundu Kabul Et
Geri git   hoSSohbeT.com Sohbet forumlari > Bilgisayar ve İnternet Dünyası > Bilgisayar - İnternet > Bilgisayar Dünyası > Programlama > C ve C++
Kayıt ol Yardım Sohbet Gazete oku Diyetsaglik Üye Listesi Ajanda Arama Bugünki Mesajlar Forumları Okundu Kabul Et



Cevapla
 
LinkBack Seçenekler Stil
Alt 04-09-08, 17:04   #1
Dokunma Yanarsın
 
aLayıNaiSyaN - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: 04-02-08
Nerden: . . .
Mesajlar: 1,981
Tecrübe Puanı: 496 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000 aLayıNaiSyaN 1000
C# \ C++ \ Java İle İlgili BİRÇOK Örnek Kodlar Burada

girdiginiz sayilarin kac tanesinin cift kac tanesinin tek oldugunu ekrana yazar..
Alıntı:

#include<stdio.h>
#include<conio.h>
int main()
{
int a;
int even,odd; /*even=cift, odd=tek*/
printf("Enter 10 numbers : \n");
scanf("%d %d %d %d %d %d% %d %d %d %d",&a);
for(a=1;a<=10;a++) {
if(a%2==0){
printf(" even\n ");
even++; }
else { printf(" odd \n");
odd++; }

}
printf(" %d even, %d odd ",even,odd);
}



----------------------------------------
bu program girilen iki sayinin ussunu bulur [2 uzeri 5= 32 gibi]
Alıntı:

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

int power(int,int); /*fonksiyon prototipi tanimliyoruz..*/ /*eger bunu yazmak istemezseniz asagidaki fonksiyonu bunun yerine yazabilirsiniz, bu prototipi yazarsaniz program yukaridan asagiya dogru kodlara baktigi icin programin yurutulmesi sirasinda bir fonksiyon oldugunu anliycaktir. bu komut sadece daha ii akis saglamak amaciyla yazilir..*/

int main(void)
{
int x;
x=power(a,b);
printf("enter 2 number please: \n"); /*burada iki sayi girmeniz isteniyor..*/
scanf("%d %d",&a,&b); /*burda ise girdiginiz 2 sayi okunuyor.we ilk sayi a,ikinci sayi ise b olarak ataniyor..*/
printf("a to the power of b = %d\n",x);
printf("-3 to the power of 4= %d\n",power(-3,4));
printf("10 to the power of 3= %d\n\n",power(10,3));
printf("x= %d ",x);
return 0;
}

int power(int base,int w) /*bu kodlarda power yani us fonksiyonun nasil isledigini acikliyor..*/
{
int x;
for(x=1;w>0;w--)
x=x*base;
return x;
}


----------------------------------------
bu program girdiginiz 2 sayinin asal olup olmadigina bakior..
Alıntı:

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

int prime(int n) /*burda fonksiyon prototipi yazmak yerine yukarida belirttigim gbi fonksiyonu direk olarak buraya yazabilirsiniz..*/
{
for(int i=2;i<n;i++)
if(n%i==0)return 0;
return 1;
}


int main()
{
//clrscr();
int x,y;
printf("Enter two number:\n");
scanf("%d %d",&x,&y);


while(y!=x)
{
if(prime(x)==1)
printf(" %d",x);
x++;
}

getch();
return 0;
}


-----------------------------------------
bu program switch leri anlamaniz icin kolay bir baslangic olabilir..
Alıntı:

#include<stdio.h>
#include<conio.h>
int main(void)
{ //clrscr();
int m,n,a,s;
m=1,n=3,a=3,k=1;
do
{
switch(m>n || a==n)
{
case 1=a++;
if(m!=n) continue;
break;
default:
do
{
m+=2;
s+=m*n;
printf("\n%d %d %d",m,s,n);
}
while(s<25);
}

a-=2;
n=m;
printf("\nA=%d N=%d M=%d S=%d",a,n,m,s);
}
while(a!=0);

}


--------------------------------------------
Alıntı:

#include<stdio.h>
#include<conio.h>
int main(void)
{ // clrscr();
int i=10,j=20;
if(i>10)
if(j>20)
if(i+j>10) printf("A");
else printf("B");
else if(j-i>10) printf("C");
else printf("E");
else printf("D");
getch();
return 0;
}


--------------------------------------------
Alıntı:

#include<stdio.h>
#include<conio.h>
int main(void)
{ clrscr();
int a,k,i,x;
a=(a=k=3,k++,k+=a++);
printf("%d %d",&a,&k);
for(a=2,i=0;i<7;i+=2)
{
x=a>i?a++:a+i; /*burada kosul operatorunu goruyoruz:?, anlami eger :'nin sagindaki kosul dogru ise 1 solundaki kosul dogru ise 0 olarak cikmasini saglar..*/
printf("%d",&x);
}
getch();
return(0);
}


----------------------------------------------
bu program saat hesabi yapar.. girdiginiz sayinin kac saat kac dakika kac saniye oldugunu bulur..
Alıntı:

#include<stdio.h>
#include<conio.h>
int main(void)
{ clrscr();
int seconds,hrs,mins,secs;
printf("Enter the time in seconds:");
scanf("%5i",&seconds);
hrs=seconds/3600;
seconds-=hrs*3600;
mins=seconds/60;
seconds-=mins*60;
secs=seconds;
printf("\n%d hrs %d mins %d secs",hrs,mins,secs);
getch();
return 0;
}


-------------------------------------------------
bu programda switch ile ilgili..
Alıntı:

#include<stdio.h>
#include<conio.h>
int main(void)
{ clrscr();
int i=0;
int k,j=1;
for(;i<=5;i++)
{
k=j++;
switch(k)
{
case 1: printf("1");
case 2: printf("2");break;
case 3: printf("3");break;
case 4: printf("4");break;
default : printf("x");break;
}
}
getch();
}

Verilen bir yıla ait takvimi ekrana yazdıran program
#include <stdio.h>
#include <conio.h>

#define BASE_YEAR 1900

int is_leap(int year);
long date_to_num(int day, int month, int year);
int which_day(int day, int month, int year);
void display_calender(int month, int year);

int month_day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char *month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul","Aug", "Sep", "Oct", "Nov", "Dec"};

int main(void)
{
int i, year;

for (; {
printf("enter year :");
scanf("%d", &year);
if (year < BASE_YEAR)
printf("year must be grater than %d\n", BASE_YEAR);
else
break;
}

for (i = 1; i < 13; i++) {
display_calender(i, year);
if (i % 3 == 0) {
printf("press any key to continue");
getch();
clrscr();
}
}
return 0;
}
/************************************************** /
int is_leap(year)
{
return (year % 4 == 0 && year % 100 != 0 || year % 400 == 0);
}
/************************************************** /
long date_to_number(int day, int month, int year)
{
int i;
long total = day;

for (i = BASE_YEAR; i < year; i++)
total += 365 + is_leap(i);

for (i = 0; i < month - 1; i++)
total += month_day[i] + (i == 1 && is_leap(year));
return total;
}
/************************************************** /
int which_day(int day, int month, int year)
{
long i = date_to_number(day, month, year);

return (int) (i % 7);
}
/************************************************** /
void display_calender(int month, int year)
{
int first_day = which_day(1, month, year);
int total_day = month_day[month - 1];
int i;

if (month - 1 == 1)
total_day += is_leap(year);
printf("Sun Mon Tue Wed Thu Fri Sat");
printf(" %s %4d\n", month_name[month - 1], year);
printf("---------------------------------\n");
for (i = 0; i < first_day; i++)
printf(" ");
for (i = 1; i <= total_day; i++) {
printf("%-5d", i);
if ((i + first_day) % 7 == 0)
putchar('\n');
}
printf("\n");
}


----------------------------------------------------------


Program ekran çıktısı olarak dünya haritasında verilen enlem ve boylama ilişkin yeri gösteriyor





Alıntı:
main(l
,a,n,d)char**a;{
for(d=atoi(a[1])/10*80-
atoi(a[2])/5-596;n="@NKA\
CLCCGZAAQBEAADAFaISADJABBA^\
SNLGAQABDAXIMBAACTBATAHDBAN\
ZcEMMCCCCAAhEIJFAEAAABAfHJE\
TBdFLDAANEfDNBPHdBcBBBEA_AL\
H E L L O, W O R L D! "
[l++-3]for(;n-->64
putchar(!d+++33^
l&1);}



carpim tablosu..

Alıntı:

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

int main(void)
{
int a,b;
a=1;
b=1;

for( ; a<=10;a++)
for(b=1;b<=10;b++)
printf("%d*%d=%d\n", a,b,a*b);

return(0);
}


---------------------------------
faktoriyel bulur..

Alıntı:

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

int main(void)
{
int n,fac,count;
clrscr();

printf("enter a number for factorial:");
scanf("%d",&n);

fac=1;
for(count=1;count<=n;++count)
{
fac=fac*count;
}
printf("fac=%d",fac);
getch();
return(0);
}


----------------------------------
girdiginiz 3 sayinin en buyugunu bulur..

Alıntı:

#include<stdio.h>
#include<conio.h>
int main(void)
{
clrscr();
int a,b,c;
int max;
printf("enter three number:\n");
scanf("%d %d %d",&a,&b,&c);
if(a>b)
if(a>c)
max=a;
else max=c;
if(b>c)
max=b;
else max=c;

printf("greatest one is=%d",max);
return 0;
}


-----------------------------------
dairenin alanini bulur..

Alıntı:

#include <stdio.h>
#include <conio.h>
#define PI 3.14

int main(void)
{
float area,
rad;
clrscr();
printf("give radius= ");
scanf("%f",&rad);

area=PI * rad * rad;

printf("that %f area. \n",area);

return(0);
}


------------------------------------
silindirin alanini we hacmini bulur..

Alıntı:

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


int main(void)
{
float A,V,r,h;
clrscr();

printf("enter radius and height:");
scanf("%f %f",&r,&h);

V=3.14*r*r*h;
A=2*3.14*r*h;

printf("A=%f V=%f",A,V);
getch();
return(0);
}


------------------------------------
2 sayinin karesini alir..

Alıntı:

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

int main(void)
{
float a,sq;
clrscr();
printf("SAYI GIR:");
scanf("%f",&a);

sq=a*a;

printf("sq=%f",sq);
getch();
return(0);
}


------------------------------------
girdiginiz sayilarin tolamini, farkini, carpimini we bolumunu bulur..

Alıntı:

#include <stdio.h>

int main(void)
{
int sum,
dif,
pro,
quo,
num1,
num2;

printf("enter two numbers:");
scanf("%d %d",&num1,&num2);

sum=num1+num2; /*sum=toplama*/
dif=num1-num2; /*dif=cikarma*/
pro=num1*num2; /*pro=carpim*/
quo=num1/num2; /*quo=bolum*/

printf("sum=%d",sum);
printf("dif=%d",dif);
printf("pro=%d",pro);
printf("quo=%d",quo);

return(0);
}



C++ analog saat bileşeni
Alıntı:

Horloge.h


#ifndef HorlogeH
#define HorlogeH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
//---------------------------------------------------------------------------
class PACKAGE THorloge : public TGraphicControl
{
private:
TTimer *Timer1;
Graphics::TBitmap *Image1;
bool FSec;
bool __fastcall CanResize(int &NewWidth, int &NewHeight);
protected:
void __fastcall Tempo(TObject* Owner);
void __fastcall Paint();
public:
__fastcall THorloge(TComponent* Owner);
virtual __fastcall ~THorloge();
__published:
__property Anchors;
__property ParentShowHint;
__property ShowHint;
__property Visible;

__property bool Seconde = {read=FSec, write=FSec, default=true};
};
//---------------------------------------------------------------------------
#endif











Horloge.cpp

#include <vcl.h>
#include <math.h> #pragma hdrstop
#include "Horloge.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
//

static inline void ValidCtrCheck(THorloge *)
{
new THorloge(NULL);
}
//---------------------------------------------------------------------------

__fastcall THorloge::THorloge(TComponent* Owner)
: TGraphicControl(Owner)
{
ControlStyle << csOpaque;
Image1 = new Graphics::TBitmap();
Timer1 = new TTimer(NULL);
Timer1->OnTimer = Tempo;
FSec=true;
Width = 120;
Height = 120;
Image1->Width = Width;
Image1->Height = Height;
}
//---------------------------------------------------------------------------
__fastcall THorloge::~THorloge()
{
delete Image1;
delete Timer1;
}
//---------------------------------------------------------------------------
bool __fastcall THorloge::CanResize(int &NewWidth, int &NewHeight)
{
NewWidth = 120;
NewHeight = 120;
return true;
}
//---------------------------------------------------------------------------
void __fastcall THorloge::Tempo(TObject* Sender)
{
Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall THorloge::Paint()
{
float n,z,u,x0,y0,x1,y1,x2,y2,x3,y3;
TDateTime heure;
TPoint points[4];
Word wHour, wMinute, wSeconde;

heure = Now();
DecodeTime(heure, wHour, wMinute, wSeconde, NULL);

// Couleur de fond.
Image1->Canvas->Brush->Color = Color;
Image1->Canvas->Pen->Color = Color;
Image1->Canvas->Rectangle(0,0,Image1->Width,Image1->Height);

// Dessin du cercle.
Image1->Canvas->Pen->Color = clBlack;
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Ellipse(2,2,118,118);

// Dessin du texte.
Image1->Canvas->Font->Name = "Arial";
Image1->Canvas->Font->Color = clBlack;
Image1->Canvas->Font->Size = 8;
Image1->Canvas->TextOut( 50,80,"CGi");

Image1->Canvas->TextOut( 55,6,"12");
Image1->Canvas->TextOut( 58,101,"6");
Image1->Canvas->TextOut( 8,53,"9");
Image1->Canvas->TextOut( 105,53,"3");

Image1->Canvas->TextOut( 81,13,"1");
Image1->Canvas->TextOut( 97,30,"2");

Image1->Canvas->TextOut( 98,76,"4");
Image1->Canvas->TextOut( 81,94,"5");

Image1->Canvas->TextOut( 33,94,"7");
Image1->Canvas->TextOut( 15,76,"8");

Image1->Canvas->TextOut( 14,30,"10");
Image1->Canvas->TextOut( 32,13,"11");

Image1->Canvas->Pen->Width = 1;

// Dessin aiguille des secondes si FSec à true.
if (FSec)
{
n = wSeconde*200/60;
z = n/100*3.14159;
u = (n+50)/100*3.14159;

x0 = sin(z)*50;
y0 = -cos(z)*50;

x1 = -sin(z)*10;
y1 = cos(z)*10;

x2 = sin(u)*2;
y2 = -cos(u)*2;

x3 = -sin(u)*2;
y3 = cos(u)*2;

points[0] = Point(x1+60,y1+60);
points[1] = Point(x2+60,y2+60);
points[2] = Point(x0+60,y0+60);
points[3] = Point(x3+60,y3+60);

Image1->Canvas->Brush->Color = clRed;
Image1->Canvas->Polygon(points, 3);
}

// Dessin aiguille des minutes.
n = wMinute*200/60 + wSeconde*200/60/60;
z = n/100*3.14159;
u = (n+50)/100*3.14159;

x0 = sin(z)*50;
y0 = -cos(z)*50;

x1 = -sin(z)*10;
y1 = cos(z)*10;

x2 = sin(u)*4;
y2 = -cos(u)*4;

x3 = -sin(u)*4;
y3 = cos(u)*4;

points[0] = Point(x1+60,y1+60);
points[1] = Point(x2+60,y2+60);
points[2] = Point(x0+60,y0+60);
points[3] = Point(x3+60,y3+60);

Image1->Canvas->Brush->Color = clAqua;
Image1->Canvas->Polygon(points, 3);

// Dessin aiguille des heures.
n = wHour*200/12 + wMinute*200/60/12;
z = n/100*3.14159;
u = (n+50)/100*3.14159;

x0 = sin(z)*35;
y0 = -cos(z)*35;

x1 = -sin(z)*10;
y1 = cos(z)*10;

x2 = sin(u)*4;
y2 = -cos(u)*4;

x3 = -sin(u)*4;
y3 = cos(u)*4;

points[0] = Point(x1+60,y1+60);
points[1] = Point(x2+60,y2+60);
points[2] = Point(x0+60,y0+60);
points[3] = Point(x3+60,y3+60);

Image1->Canvas->Brush->Color = clYellow;
Image1->Canvas->Polygon(points, 3);

Canvas->Draw(0,0,Image1);
}
//---------------------------------------------------------------------------
namespace Horloge
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(THorloge)};
RegisterComponents("Beyaz", classes, 0);
}
}




sayısal loto programı
Alıntı:

#include"stdio.h"
#include"stdlib.h"
#include"time.h"
void goster();
int kolon[6];

void main()
{
int n,deger,j,w,m;
do
{
printf("KAC KOLON OYNAMAK ISTERSINIZ?\n");
scanf("%d",&n);
if(n<=0)
printf("KOLON SAYISI 0 veya Daha Kucuk OLAMAZ\n");
}
while(n<=0);

srand(time(NULL));
for(int i=0;i<n;i++)
{
for(j=0;j<6;j++)
{

deger=rand()%49+1;
for(m=0;m<=j;m++);
if(kolon[m]==deger)
deger=rand()%49+1;
else
kolon[j]=deger;


}
goster();
printf("%d.kolon\n",i+1);

for(w=0;w<6;w++)
{
printf("=>%d\t",kolon[w]);
}
printf("\n");
printf("*******************\n");
}
}

void goster()

{
int gec,i,j;
for(i=0;i<5;i++)
{
for(j=i+1;j<6;j++)
{
if(kolon[j]<kolon[i])
{
gec=kolon[i];
kolon[i]=kolon[j];
kolon[j]=gec;
}
}
}
}


Alıntı:

Hepsini Seç#include<stdio.h>
FILE *fp;
char ad[15],sy[20],adr[50],tel[15],ceptel[20];
char sec;
main()
{
fp=fopen("BILGILER/TELEFON REHBERI.txt","a");
do
{
printf("\t\t\tBILGILERI DIKKATLI GIRINIZ\n\n");
printf("\t\tADI :");
scanf("%s",&ad);
printf("\t\tSOYADI :");
scanf("%s",&sy);
printf("\t\tADRESI :");
scanf("%s",&adr);
printf("\t\tTELEFONU :");
scanf("%s",&tel);
printf("\t\tCEP TELEFONU :");
scanf("%s",&ceptel);
fprintf(fp,"AD:%s %s\n",ad,sy);
fprintf(fp,"ADRES:%s\nTEL:%s\nCEP TEL:%s\n",adr,tel,ceptel);
printf("\n\n");
printf("\t\tDEVAM ETMEK ISTIYORMUSUNUZ?(E/H)");
fflush(stdin);
sec=getchar();
}
while(sec!='h' && sec!='H');
fclose(fp);
getchar();
}
__________________
aLL Hope iS Gone

aLayıNaiSyaN isimli Üye şimdilik offline konumundadır  
Digg this Post!Bookmark Post in Technorati
Alıntı ile Cevapla
Cevapla

  • Submit Thread to Digg Digg
  • Submit Thread to del.icio.us del.icio.us
  • Submit Thread to StumbleUpon StumbleUpon
  • Submit Thread to Google Google
  • Bookmarks

    Seçenekler
    Stil

    Yetkileriniz
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is Açık
    Smileler Açık
    [IMG] Kodları Açık
    HTML-KodlarıKapalı
    Trackbacks are Açık
    Pingbacks are Açık
    Refbacks are Açık



    Bütün Zaman Ayarları WEZ olarak düzenlenmiştir. Şu Anki Saat: 13:26 .


    Powered by vBulletin Version 3.8.7
    Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
    Search Engine Friendly URLs by vBSEO 3.5.0 RC2
    Sohbet ve Sohbet odalari sitesi

    Sohbet Chat Forum Oyunlar1