43
Welcome to AMUROBOCLUB

Basics of Embedded C

Embed Size (px)

DESCRIPTION

Embedded C Basics from AMU RoboClub

Citation preview

Welcome to AMUROBOCLUBC programming basicsC s genera-purpose structured programmng anguage or hgh eve anguage.It was deveoped by Denns Rtche n 1970s at Be aboratores.C supports a arge no. of operators and a arge no. of brary functon.C s most popuar anguage used for system programmng ,such as deveopment of compers, nterpreters , assembers , operatng system keUNIX.C-Programming:A typca C program has 3 sectons:#ncude< stdo.h >//Header e secton #ncude< stdo.h >vod man( ){nt a,b; //Type decaraton secton//Instructon secton } C program structure#ncude man(){ prntf("Heo Word");}A simple ProgramA brary functon s a sef-contaned program thatcarresoutsomespeccasweas dened tasks.Thefunctonprototypeorthereferences dened n the header es secton so we have to ncude them n the begnnng of program.Exampe: #ncude, #deneLibrary function:Thestatementsusedtochangethe controownaprogramarecaedthe controstatements or contro structures n C. Contro statements:Logca f structureIf-ese structureNested f-eseUncondtona goto statementSwtch structuresControl statements:The ogca f structure checks a gven ogca condton and transfers the contro accordngy. Synta:If(condton){Statement;}Exampe: f(x==3){Y=2*x;}!f Statement:#ncude nt man(){ nt a=1;If(a==1) {prntf("true ogc"); }If(a==0) {prntf("fase ogc"); }return 0;}"ampleThef-esestructuresmoreusefuthan ogca f structure.Synta:f(expresson){ S1; }ese { S2; }Exampe:f(==0){ s=s+1;}ese { s=s-1; }!f else Statement:#ncude nt man(){ nt a=1;If(a==1) {prntf("true ogc"); }ese{prntf("fase ogc"); }return 0;}"ampleC provdes three oop structures to perform oopng operatons or teratons, n whch a setofstatementscanberepeatedy executed as ong as condton s satsed.Loops are:whe Do wheForLoops:It s smar to the whe-oop structure except that the condton s checked at the end of the oop.Synta:do{S1;} whe(condton);Exampe:do{ =+1;} whe(