C language notes (a.p)

Download C language notes (a.p)

Post on 11-Aug-2014

5.841 views

Category:

Automotive

3 download

Embed Size (px)

DESCRIPTION

My Best Collection of 'c' language program Notes.......!!!

TRANSCRIPT

<ul><li>C LANGUAGE POP OOP ( Procedure Oriented program ) ( Object Oriented Program ) FUNCTION BUILT IN FUNCTION USER DEFINE FUNCTION1) 1959 ALGOL ( Algoritham Oriented Language )2) 1962 BCPL ( Basic Common Program language )3) 1972 Dennis Ritchi ( Bell Laboratory ) [ USA ] c Turbo C2 c Turbo C3 c &amp; C ++ (Tc300) (Tc)C:Windows&gt;cd.. EnterC:&gt;Cdtc EnterC:Tc&gt;CdBin EnterC:TcBin&gt;Tc Enter Structure of C Program# include# include Void main ( ){Clrscr ( );Printf ( Message 1);CREATE BY [ A.P ] 1 </li><li>C LANGUAGEPrintf ( Message 2); } ( The lines up &amp; down Type n )} 1) Compile Alt + F9 2) Run Program Ctrl + F9 3) Display Final Output Alt + F5 Data Types 1) Integer Number without Decimal Range- ( -31768 to +31767 ) Format- ( % d ) Memory size- 2 Byte Example- int a,b 2) Float Decimal Values Range- 10-38 to 1038 Memory size- 4 byte Format- ( % f ) Example- float x,y 3) Double- Range-10-38 to 10308 Memory size- 8 bytes Format- ( % l d ) Example- double a,b 4) Long Double Memory size- 10 byte Format- ( %L ) Example- x,y 5) Character- Memory size- 1 byte Format- ( % c ) For one Letter ( % s ) For strength Program 1 #include #include void main () {CREATE BY [ A.P ] 2 </li><li>C LANGUAGE int num1,num2,c; clrscr(); num1=20; num2=2; c=num1+num2; printf("nTotal=%d",c); c=num1-num2; printf("nSub=%d",c); c=num1*num2; printf("nMul=%d",c); c=num1/num2; printf("nDiv=%d",c); getch(); } Program 2 #include #include void main () { int num1,num2,c; printf("nEnter 1st no."); scanf("%d",&amp;num1); printf("nEnter 2nd no."); scanf("%d",&amp;num2); c=num1+num2; printf("nTotal=%d",c); getch(); } Operator 1) Arithmetic operator - +, -, *, / , % A = 100 % 6 Output A = 4 2) Relational Operator - &lt; - Less than &gt; - Greter than &lt; = = - Less than equal toCREATE BY [ A.P ] 3 </li><li>C LANGUAGE &lt; = = - Greter than equal to = = - Equal to ! = - Not equal to 3) Logical operator 1) &amp;&amp;- And 2) | | - Or 3) ! - Not operator 4) Unary operator 1) + + - Inerement operator 2) - - - Decrement operator 5) Assignment operator ( = ) A = A+5 A + = 5 A = A-3 - A - = 3 A = A*2 - A * = 2 6) Size of operator Long double x; Int a; A = size of ( x ); Program 3 #include #include void main() { int h,e,m,tot; float per; clrscr(); printf("nEnter marks of 3 subjects:"); scanf("%d%d%d",&amp;h,&amp;e,&amp;m); tot=h+e+m; per=((float)tot/300)*100; printf("nTotal=%d",tot); printf("nper=%f",per); if(per&gt;60) printf("nFrist"); else if(per&gt;45&amp;&amp;per=36&amp;&amp;perb&amp;&amp;a&gt;c) printf("nA=%d",a); else if (b&gt;a&amp;&amp;b&gt;c) printf("nB=%d",b); else printf("nC=%d",c); getch(); } Program 5 #include #include void main () { char ch; clrscr(); printf("nEnter one Letter:"); scanf("n%c",&amp;ch); if(ch==a||ch==e||ch==i||ch==o||ch==u) printf("nLetter is vowel"); else printf("nEnter is not vowel"); getch();CREATE BY [ A.P ] 5 </li><li>C LANGUAGE } Program 6 #include #include void main () { int year; clrscr(); printf("nEnter Year"); scanf("%d",&amp;year); if(year%4==0) printf("nLeap Year"); else printf("nNot leap Year"); getch(); } Program 7 #include #include void main () { int a; clrscr(); a=1; while(a=1) { printf("n%d",a); a=a/2; } getch(); } Program 11 #include #include void main() { int a,b; clrscr(); a=1; while(a</li></ul>