C

366 views

Published on

C language

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
366
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

C

  1. 1. „C‟ Programming language Language: - language is a medium of communication. Communication: - It is two way process. Programming: - It is a set by step execution Ex. Birthday party Programming Language: - The language we need to interact with the computer is called programming language. „C‟ language was developed in 1970‟s at bell laboratories by Dennis Ritchie  Computer is first made for doing large amount of calculation.  Programme is set of instructions. Programming language 1) High level 2)Low level Low level language: - Low level languages are the machine level and assembly language. 1) Machine language:-computers are understands only digital signals. Which are binary digit o &1 the machine language consists of instructions that are in binary 0 or 1. Computer understanding machine level language 2) Assembly language: - It is the modified form of machine level language assembly language is given in English like words such as , add, sub, etc High level language:-Use of operators interacts of mnemonic code the solution of mnemonic codes (they work on English language) because for them we need to use and learn all these coded. Ex. Operators +,-,*, / etc COBOL ==== Business Purpose FORTON ==== Calculations Purpose PASCAL====Science Purpose........etc  System independent- via OS  These are like English language it is easy to understand the programme of high level language.  Every language has its own compiler or interpreter Ex. COBOL (business) basic Pascal (calculation) etc.  System deportment  Which can interact with system directly
  2. 2.  In low level programming are made for machine. To make the computerized machine.  We use coding in machines because its interacts with system directly. Drawback:  These languages were for some specific task.  Can use only predefined function and cannot modified it no use programmer not bit programming (system programming) Hence assembly language program must be translated into machine language. The translator that is used for translating is called “assembler” English==== (H.L.L) ========Compiler===== (L.L.L) ===== 0 & 1 148 languages are working at present time. /* this program...*/: - The symbols /* and */ delimit a comment. Comments are ignored by the compiler 1, and are used to provide useful information for Humans that will read the program. Bit level Programming: Software: - A set of one or more programs designed to control the operation of a computer system. They are general programs written to assist humans in the use of computer system and for making the operation of the computer system more effective and efficient. Software System software Application Software 1) System software: - Aaise software jo hardware ko chalane ke lia able banayein. Ex. Drivers, keyboard, Mouse, Operating System 2) Application Software: - Application software for performing particular task. It is requirement of user Ex. Windows‟s media player, M.S offices, tally, etc. System software Middle level language Application software Note: - C is a HLL with low level features that is why it is known as middle level language.
  3. 3. ALGOL 60................................in 1960 CPL......................................... BCPL................................................... B (ken Thomson)..................... C.............................................. in 1972 12 years C: - c is stable language because develop Dennis Ritchie language at AT ans T Bell Laboratory, USA .h: - Extinction of header file. Extinction, It is the identification of file. Ex- .mp3, .doc, .txt, etc Function: -It is the groups of statement or it is the block In C language 48 header files and 3200 function. There are two typesFirst formatted function and second is unformatted function. 1) Stdio.h: - (standard input output header file) Ex- printf (); scanf (); gets (); puts (); etc Question: what is f? Answer: -it is used f end of the function. And other unformatted function. String: -sequence of the character “hello”. Conio.h: - (console input/output) Delimiters: - delimiters are used for syntactic meaning in C. These are as given follows. Delimiters : Name Colon syntactic meaning used for label ; Semicolon end of statement () Parentheses Used in expression [] Square brackets {} statements Curly Braces # directive Hash , Comma Used for array Used for block of Pre-processors Variable delimiter C Character Set: - The character that are used to form the words, numbers and expressions. The character are classified as follows    Letters Digits Special Characters
  4. 4. Letters: C language comprises the following set of letters to form a standard program. They are : A to Z in Capital letters. a to z in Small letters. Special Characters: C language contains the following special character in association with the letters and digits. Symbol Meaning ~ ! # $ % ^ & * ( ) _ + | ` = { } [ ] : " ; < > ? , . / Tilde Exclamation mark Number sign Dollar sign Percent sign Caret Ampersand Asterisk Lest parenthesis Right parenthesis Underscore Plus sign Vertical bar Backslash Apostrophe Minus sign Equal to sign Left brace Right brace Left bracket Right bracket Colon Quotation mark Semicolon Opening angle bracket Closing angle bracket Question mark Comma Period Slash
  5. 5. Function: - function is a group of statement or a block of code, which is executed step by step when it is called. Generally hm function ka use value return karne ke lia karte hai. Kisi kaam ko baar baar repeat karne ke lia hm function ka use karte hai. Main advantage yeh hai ki reuse means reusability bole toh reusable . There are two types 1.Predefine 2.User define 1.Predefine: yeh programmer ke through banayi jati hai. 2.User define yeh user ke through but bina predefine function ke help ke bina user define nhi banaya jaa skta hai Q ki statement ki code hmare bas kin hi hai…….. Way of writing of create function or way of coding Syntax: likhane kaa tarika hm function ko create karne ke kia kaise likhenge Syntax:< > (angular bracket)  that filled mandatory [ ] ( optional bracket)according to wise(jararut ho toh lagao yaa mat lagao) Syntax: <return type><function name>([function parameter]) { Body of statement } 1: <return type> Jis type kaa data aap return karna chahte hai aap kar skte ho jaise.. Intfloatdouble etc…. *Agar aap kisi type kaa address return karna chahte hain toh pointer laga do. Jaise ….int*float*double* etc ** Kisi bhi type kaa type kaa address return karana chahte hai toh toh void* lagalo. Agar aap return nhi karna chahte ho toh void laga do. Return type me data type ata ayega…by default agar aaap koi data type nhi lete hain toh wo int laga leta hai . 2: <function name> jo variable pe rule hai same wahi 8 rule yaha bhi kareenge. 1.no space allow no use special char etc. Parameter[]; Parameter me hm variable dete hain jise hm signature kahte hain ** jitney parameter ki variable declare kia ho calling ke time bi utne hi variable hone chahia. Jaise…
  6. 6. Void show (int a,int b) { } Show(10,x); Void show(int a,int b,float c) // show is the signature { } Show(10,x,10.0); Function hm four type ke create karte hain. 1- Without return type without parameter Ex- void show() // called fuction Printf(“welcome to the world of funtion”); } Void main(); calling funtion { Clrscr(); Show(); function calling Getch(); } 2- Without return type with parameter Ex- void prime(int x) 3- With return type without parameter Ex- int show() 4- With return type with parameter Ex- int add(int a,int b) Hm function kaa ek program banate hai, Void show() { Printf(“enter the would of funtion”); } Void display() { Show(); } Void main() { Clrscr(); Display(); Getch();
  7. 7. } Jab bhi aap function banaye wo calling function ke upper hi banaye Q ki hmra compilre waha tak nhi pahuch pata hain wo toh uska proto type matching check karta hain. Wo matching -2 dhundhega toh chalega agar aap calling function ke niche banana chahte hain toh upper aap ko uska proto type declear(likhana hoga) karna hoga. Ex. Void show(); Void main() { Clrscr(); Show(); Getch(); } Void show() { Printf(“hellow”); } **pahle sare proto type likh lo phir coading karo okay Need of parameter: 1----user se value lena 2—fixed value 3— function ke ander function Note--- aalag -2 funtion me same name ke variable ho skte hain. Ex— Void add1(int a,int b) { Printf(“%d”,a+b); } Void main() { Int a,b; Clrscr(); add1(10,20); Add1(pow(2.3),sqrt(1)); Pirintf(“%d%d”,a,b); Add1(a,b) Getch(); } Return statement can return only one value at a time…………..
  8. 8. Ex-1 Int add (int a,int b) { Return a+b; } Ex-2 Int add (int a,int b) { Return a+b; // yaha se program teminate ho gayega Return a-b; } Note: hme saare function ke return type banana chahia jinse koi ek value aati ho Toh waha return karao Call by value call by rreference:::: jab aap fuction ko call karenge as a parameter koi vale pass karenge toh waha call by value hoga.. 100% me se 95% call by value se hi function ki calling hoti hai. Call by reference:-------------------------------------------------------------------------------------------- _ _ _ __________________________________________________________________________ ______ Header file: groups of function. Ex. <My.h> Codind…….. int iseven(int n) Functin of cheak even or not { if(n%2==0) return 1; else return 0; } int isleap(int n) { if((n%4==0 && n%100!=0)||(n%400==0)) return 1; else return 0; }
  9. 9. int isprime(int n) { int i; for(i=2;i<=n/2;i++) { if(n%i==0)return 0; } return 1; } long length(long n) { int count=0; while(n>0)//123>0,12>0,1>0,0>0 { count++;//count=0+1=1+1=2+1=3 n=n/10;//123/10=12/10=1/10=0 } return count;//3 } long sum(long n) { //123 long s=0; while(n>0) { s=s+n%10; n=n/10; } return s; } long rev(long n) { //123 long s=0; while(n>0) { s=s*10+n%10; n=n/10; } return s; } ispal(long n) { long s=0; long x;
  10. 10. x=n; while(n>0) { s=s*10+n%10; n=n/10; } if(s==x)return 1; else return 0; } isarm(long n) { long s=0,x; x=n; while(n>0) { s=s+(n%10)*(n%10)*(n%10); n=n/10; } if(s==x)return 1; else return 0; } int fact(int n) { int i,x=1; for(i=1;i<=n;i++) { x=x*i; } return x; }

×