1 / 22

بسم الله الرحمن الرحيم

بسم الله الرحمن الرحيم. فروشگاه محصولات نرم افزاری و آموزشی سیب سرخ فیض آبادی09157711812. معرفي سرفصلها ومنابع :.

hedy
Télécharger la présentation

بسم الله الرحمن الرحيم

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. بسم الله الرحمن الرحيم فروشگاه محصولات نرم افزاری و آموزشی سیب سرخ فیض آبادی09157711812 Shop.sibsorkh.ir

  2. معرفي سرفصلها ومنابع : مقدمه - شناسه ها - داده ها - ثابتها - عملگرها - برخي توابع كتابخانه اي - دستورات ورودي و خروجي - دستورات حلقه و شرط - توابع و پارامترها و توابع بازگشتي - متغييرهاي محلي و سراسري - آرايه ها توابع رشته اي - اشكال زدائي برنامه و آزمايش آن - كلاسهاي حافظه - اشاره گرها - ساختارها ( ركورد ) - يونيون - ليستهاي پيوندي - متغييرهاي شمارشي - فايلها - وقفه ها - ماكروها - پيش پردازنده ها – گرافيك-پورت ها - كار مستقيم باRAM - اسمبلي درC - برنامه هاي مقيم در حافظه منابع : 1-برنامه نويسي به زبانC - جعفر نژاد قمي 2-برنامه نويسي با توربوC - رابرت لي فور - حسن كيميائي - نشر انقلاب 3-توربوC یا C++ -شركت بورلند - هربرت شيلد - مك گروهيل 4-كتاب جامع برنامه نويسي C - امير اسعد انزاني - نشر جهاد 5- PC System Programing - سه جلدی Shop.sibsorkh.ir

  3. C اصطلاحاً Case Sensitive است . شناسه : < Letter | _ > < Letter | Digit | _ > . . . < Letter | Digit | _ > 31كاراكتر int i , j ; char c , s[5]; float f ; double d1 ; int ، 2 بایت char ، 1 بایت داده ها float ، 4 بایت double ، 8 بایت Shop.sibsorkh.ir

  4. Data_Type short int long int unsigned int unsigned = unsigned int unsigned long int unsigned char long float long double Size 2 4 2 4 1 8 10 Range -32768 ... 32767 -231 ... (231-1) 0 ... 65535 0 ... (232-1) 0 ... 255 eg. : short int i , j ; long double d1 ; Shop.sibsorkh.ir

  5. ثابت ها : صحيح : 12 , 012 , 0x12 , 0X12 , 12U , 12L , 12UL اعشاري : 3e+5 , 3e5 , 3.2e-4 كاراكتر : ‘A’ رشته : “Computer” ثابتهاي نمادين ( سمبوليك ): const float pi = 3.14 ; const int id = 20 ; // const id = 20 ; توضيحات( Comment ) : // یا /*…………*/ Shop.sibsorkh.ir

  6. عملگرها ( Operators ) : عملگرهاي محاسباتي : ( + , - , * , / , % ) 5 / 2 = 2 , 5.0 / 2 = 5 / 2.0 = 2.5 , int ( 9.5 ) % 2 = 1 عملگرهاي يكتائي : ( - , + + , - - , sizeof ) + + n ; // n = n + 1 ; n + + ; عملگرهاي مقايسه اي و منطقي : ( < , > , <= , >= , = = , != , && , || , ! ) عملگرهاي جايگزيني : ( = , += , -= , *= , /= , %= ) s += n ; // s = s + n ; x = y = 3 ; عملگر شرطي ( ?: ): max = ( a > b ) ? a : b; اولويت عملگرها : ( يكتائي ـــ * , / ـــ + , - ـــ مقايسه اي ـــ = = , =! ـــ && ـــ || ـــ جايگزيني( Shop.sibsorkh.ir

  7. دستور ورودي ( scanf ) : scanf( control string , arg1 , arg2 , ... , argn ) ; int x ; float y ; scanf( “%i”, &x ) ; scanf( “%i %f” , &x , &y ) ; char c , s[10] ; scanf( “%c” , &c ) ; scanf( “%s” , s ) ; %c - %i - %d = Dec - %o = Oct - %x = Hex - %f , %e , %g %s - %u - %li , %ld - %lf - %Lf , %Lg , %Le scanf ( “%i , %i” , &a , &b ) ; // , : ; . scanf ( “ %[ abcd]” , s ) ; scanf ( “%[^\n]” , s ) ; scanf ( “%[^~]” , s ) ; Shop.sibsorkh.ir

  8. دستورخروجي ( printf ) : printf ( control string , arg1 , arg2 , ... , argn ) ; int x ; float y ; printf( “%i”, x ) ; printf( “%i %f” , x , y ) ; char c , s[10] ; printf( “%c” , c ) ; printf( “%s” , s ) ; %c - %i - %d = Dec - %o = Oct - %x ,%X = Hex - %#o - %#x %f ( شش رقم اعشار) , %e (نمادعلمي ) , %g ( بدون صفرهاي اضافي) %s - %u - %li , %ld - %lf - %Lf , %Lg , %Le , %n , %p printf ( “%5i %5.2f ” , x , y ) ; printf ( “Name = %3s ” , str ) ; = %5s اگر طول رشته بزرگتر از 5 باشد printf ( “%10.8s” , str ) ; هشت كاراكتر و دو فضاي خالي int n=printf(“abc\n%nde”,&x) ; // x=4 , n=6 printf(“%p %p %p”,&x,&y,&c); //211F:2406211F:2402211F:2401 \a = Alarm , \b = Backspace , \n = New Line , \t = Tab , \r = Carriage Return , \” , \’ , \\ , \? , \0 , %% eg. : printf( “a%%s” ) ; printf ( “ a\\b “ ) ; Shop.sibsorkh.ir

  9. دستور ورودي ( cin ) و دستور خروجی ( cout ) : cin >> var1 >> var2 >> . . . ; //نوع متغییر را تشخیص می دهد int a; float b; cin >> a >> b ; // cin >> a , b ; غلط است char ch ; cin.get(ch) ; // cin >> ch ; // ch=cin.get( ); char s[5] ; cin >> s ; cin.get( s, l ) ; // cin.getline( s, l ); l-1 کاراکتر یا 5 تا . نباید l ازطول رشته بزرگتر باشد. cin.get ( s , l , ch ) ; // cin.getline(s , l , ch ) ; l-1 کاراکتر یا رسیدن به کاراکتر ch ، هر کدام زودتر اتفاق افتاد. cout << var1 | Expr.1 << var2 | Expr.2 << . . . ; cout <<”Sum “<< a <<” and “ <<b<<“ = “<<a+b<<endl ; //’\n’ cout.put(ch) ; cout.write( s , l ); // write l character of s cout<<hex<<255;//ff cout<<31;//1f cout<<dec<<0xff ;//255 Shop.sibsorkh.ir

  10. توابع كتابخانه اي : abs( i ) - fabs( d ) - ceil( d ) - floor( d ) - cos( d ) sin( d )- tan( d )- exp( d )- exp( ld ) - fmod(d1,d2) fmod( ld1 , ld2 ) - log( d ) - pow( d1 , d2 ) pow( ld1 , ld2 )- getchar( ) - putchar( c ) - getch( ) getche( ) - rand( ) - randomize( ) - sqrt( d ) toascii( c ) - tolower( c ) - toupper( c ) - atoi ( s ) atof( s ) - atol ( s ) - gets( s ) - puts( s ) برنامه نويسي واكنشي يا محاوره اي - لانه اي ( تورفتگي ) Shop.sibsorkh.ir

  11. دستورات : الف) ساده 1- جایگزینی : x = 2 ; y = pow ( x , 2 ) + 1 ; 2-افزايشي يا كاهشي : + + x ; x - - ; 3-فراخواني توابع يا زير برنامه ها : clrscr( ) ; printf(“%lf “ , n ) ; ب) مركب : تعدادي دستور بين { } ) ) ج) كنترل : ( شرط و حلقه ( Shop.sibsorkh.ir

  12. دستور if : Syntax: if ( exp ) statement1 ; [ else statement 2 ; ] eg.1: if ( a > b ) printf( “%i”, a ); eg.2: if ( a > b ) printf( “%i”, a ); else printf( “%i”, b ); if ( a > b ) printf( “%i”, a ); else printf( “%i”, b ); eg.3: if ( a > b ) { int t = a ; a = b ; b = t ; } eg.4: if ( m>=10 && m<99 ) printf( “2 Digit”); Shop.sibsorkh.ir

  13. دستور switch : Syntax: switch ( exp ) statement (بايد صحيح يا كاراكتر باشد exp ) eg. : switch ( x ) { case 0 : printf ( “Zero” ) ; break ; case 1 : printf ( “One” ) ; break ; case 2 : case 3 : printf ( “Two or Three” ) ; break ; default : printf ( “Greater Than or Equal Four “ ) ; } Shop.sibsorkh.ir

  14. دستورات while و do ... while : Syntax: while ( exp ) statement ; do statement while ( exp ) ; eg.1: x = 1 ; while ( x <= 10 ) { printf ( “%i \n “ , x ) ; x + + ; } // while ( x <= 10 ) printf (“%i \n “ , x + + ) ; eg.3: x = 1 ; while ( x <= 10 ) printf (“%i \n “ , + + x ) ; // do printf (“%i \n “ , + + x ) ; while ( x <= 10 ) ; eg.2: x = 1 ; do { printf ( “%i \n “ , x ) ; x + + ; } while ( x <= 10 ) ; Shop.sibsorkh.ir

  15. دستور for : Syntax: for ( [exp1] ; [exp2] ; [exp3] ) statement ; eg.1: int x ; for ( x = 1 ; x <= 10 ; x ++ ) printf(“%i\n”, x ) ; int x = 1 ; for ( ; x <= 10 ; ) printf(“%i\n”, x ++ ) ; int x = 1 ; for ( ; ; ) { printf(“%i\n”, x ++ ) ; if (x > 10 ) break ; // همه دستورات حلقه } int x = 1 ; for ( ; x <= 10 ; x ++ ) printf(“%i\n”, x ) ; Shop.sibsorkh.ir

  16. دستور Continue : eg.1: s = 0; for ( i = 1 ; i<=10 ; i++) { scanf(“%i”,&n); if ( n < 0 ) continue ; s += n ; } eg.2: s = 0 ; i = 1 ; while ( i <= 10 ) { scanf(“%i”,&n); i ++ ; if ( n < 0 ) continue ; s += n ; } Shop.sibsorkh.ir

  17. عملگر , : eg.1: if ( a > b ) t = a , a = b , b = t ; eg.2: for ( x = 1 , y = 5 ; x <= 10 ; x ++ ) printf(“%i\n”, x * y) ; eg.3: for ( float x = 1 ; x <= 10 ; printf(“%f\n”, x ) , x += 0.1 ) ; eg.4: for ( x=12 , y=15 ; x<99 ; printf(“%i %i\n”, x,y) , x+=4 , y+=5 ) ; Shop.sibsorkh.ir

  18. دستور goto : eg.1: int x = 1 ; L1: printf(“%i\n”, x ) ; x ++ ; if ( x <= 10 ) goto L1; Identifier Shop.sibsorkh.ir

  19. Data_Type Array_name [ Index 1 ] [ Index 2 ]... ; char s[ 10 ] ; int ar[ 5 ] ; float mark[ 30 ][ 5 ] ; آرايه ها : char s[10]; scanf("%s",s); printf("%s",s); char s[10]; i=0; while(1) { scanf("%c",&s[i]); if (s[i]=='\n') break; i++; } s[i]='\0'; puts(s); int m[5]; for (i=0 ; i<5 ; i++) scanf("%i",&m[i]); for (i=0 ; i<5 ; i++) printf("%i",m[i]); Shop.sibsorkh.ir

  20. float a[2][3]; for(i=0 ; i<2 ; i++) for(j=0 ; j<3 ; j++) scanf("%f",&a[i][j]); for(i=0 ; i<2 ; i++) for(j=0 ; j<3 ; j++) printf("%f ",a[i][j]); آرايه دوبعدي مرتب كردن آرايه int i,j,t,m[5]; for (i=0 ; i<5 ; i++) scanf("%i",&m[i]); for (i=0 ; i<4 ; i++) for (j=i+1 ; j<5 ; j++) if (m[i]>m[j]) { t=m[i]; m[i]=m[j]; m[j]=t; } Shop.sibsorkh.ir

  21. مقدار دهي اوليه آرايه ها : int a[3] = { 3, 4, 5 } ; // int a[ ] = { 3, 4, 5 } ; int b[3] = {0} ; // { 0, 0, 0 } int c[5] = { 2 } ; // { 2, 0, 0, 0, 0 } int d[5] = { 2, 3 } ; // { 2, 3, 0, 0, 0 } int e[2] = { 3, 4, 5 } ; خطا char s[4] = “ali” ; // {‘a’, ‘l’, ‘i’ } , {‘a’, ‘l’, ‘i’ ,’\o’ } float f[3][2] = { { 2, 1 }, { 3, 4 }, { 9, 3 } } ; float f[3][2] = { { 2, 1 }, { 3, 4 }, { 9, 3 } } ; float f[3][2] = { 2, 1, 3, 4, 9, 3 } ; float g[3][4] = { { 2 } , { 0, 5 } , { 1, 2 } } ; Shop.sibsorkh.ir

  22. توابع روي رشته ها : char s1[10] , s2[5]; s1 = “Computer” ; خطا strcpy ( s1 , “Computer” ) ; strcpy ( s2 , s1 ) ; strncpy ( s1 , s2 , n ) ; // s2=“abcde” , n=3 => s1=“abcputer” l = strlen( s1 ) ; // l = 8 i = strcmp( s1 , s2 ) ; // s1=s2 => i=0 s1>s2 => i>0 strcmpi( s1 , s2 ) // Ignore Case Sensitivity strcat( s1 , s2 ) ; // Append s2 to s1 strncat( s1 , s2 , n ) ; // Append n character from s2 to s1 strrev( s1 ) ; // s1 = “ali” => s1 = “ila” strlwr( s1 ) ; // s1 = “AaBb” => s1 = “aabb” strupr( s1 ) ; // s1 = “AaBb” => s1 = “AABB” Shop.sibsorkh.ir

More Related