1 / 10

C Dili Temel Örnekler

C Dili Temel Örnekler. 1den 50ye kadar dizilerin sayma. # include &lt; stdio.h &gt; # include &lt; stdlib.h &gt; main() { int i,matrix [50]; for (i=0;i&lt;=49;i++){ matrix [i]=2*i+1; printf (&quot;%d<br>&quot;, matrix [i]);} system (&quot; pause &quot;); }. 10 lu dizi. # include &lt; stdio.h &gt;

callicoat
Download Presentation

C Dili Temel Örnekler

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C Dili Temel Örnekler

  2. 1den 50ye kadar dizilerin sayma • #include<stdio.h> • #include<stdlib.h> • main() { • inti,matrix[50]; • for(i=0;i<=49;i++){ • matrix[i]=2*i+1; • printf("%d\n",matrix[i]);} • system("pause"); • }

  3. 10 lu dizi • #include<stdio.h> • #include<stdlib.h> • intfind(int x[]); • #define N 10 • main() { • intgrades[N]={23,54,9,78,96,55,34,21,7,8}; • intmin; • min=find(grades); • printf("Themin element of theArray is=%d",grades); • intfind(int x[]); • { • inti,ek; • ek=x[0]; • for(i=1;i<N;i++){ • if(x[i]<ek) • ek=x[i]; } • return ek; • } • system("pause"); }

  4. Bir sayinin karesi • #include<stdio.h> • #include<stdlib.h> • int karesi(int); • main(){ • intx,y; • printf("Karesi alinacaksayiyi giriniz:"); • scanf("%d",&x); • y=karesi(x); • printf("Sayinin karesi %d'dir.",y); • system("pause");} • int karesi(int a){ • int b; • b=a*a; • return b; • }

  5. Çemberin alan çevresi • #include<stdio.h> • #include<stdlib.h> • #include<math.h> • floatarea(float); • floatcircumference(float); • float pi=3.1416; • main(){ • floata,b; • a=area(10.0); • b=circumference(10.0); • printf("Area=%f,circumference=%f\n",a,b); • system("pause"); • } • floatarea(floatradius){ • return(pi*radius*radius); } • floatcircumference(floatradius){ • return(2*pi*radius); }

  6. Dizi ortalaması • #include<stdio.h> • #include<stdlib.h> • main(){ • intgrades[5], total=0,k; • floatavg; • for(k=0;k<5;k++){ • printf("%d element=",k+1); • scanf("%d", &grades[k]); } • for(k=0;k<10;k++){ • total=total+grades[k]; } • avg=total/5,0; • printf("Average of grades=%f",avg); • system("pause"); • }

  7. Faktöryel • #include<stdio.h> • #include<stdlib.h> • long factorial(long); • main() { • printf("%d\n",factorial(5)); • system("pause"); • } • long factorial(long number) • { • if(number<=0) • return 0; • else • return(number*factorial(number-1)); • }

  8. Örnek • #include<stdio.h> • #include<stdlib.h> • main(){ • inta,b,c,d,e; • a=10; • b=4,3; • c=4,8; • d='A'; • e=4,3+4,8; • printf("a=%d\n",a); • printf("b=%d\n",b); • printf("c=%d\n",c); • printf("d=%d\n",d); • printf("e=%d\n",e); • printf("b+c=%d\n",b+c), • system("pause"); }

  9. Örnek1 • #include<stdio.h> • #include<stdlib.h> • main(){ • floata,b,c,d,e,f; • a=1/3; • b=1/30; • c=1,0/3; • d=1,0/3,0; • e=(float)1/3; • f=(float)(1/3); • printf("1 dividedby 3 is %f\n",a); • printf("1 dividedby 30 is %f\n",b); • printf("1,0 dividedby 3 is %f\n",c); • printf("1,0 dividedby 3,0 is %f\n",d); • printf("\n Thefloatcasting of\n"); • printf("1 dividedby 3 is %f\n",e); • printf("\n f equals %f\n",f); • system("pause"); }

  10. Zar atma • #include<stdio.h> • #include<conio.h> • #include<stdlib.h> • voiddice(void); • main(){ • printf("Pressanykeytothrowdice,'q' keytoquit...\n"); • while(getch()!='q'){ • dice(); • } • system("pause"); • } • voiddice(void) { • printf("Youget %d onemorethrow?\n",rand()%6+1); • }

More Related