0% found this document useful (0 votes)
8 views

computer long

The document outlines the steps in programming, which include defining the problem, planning the solution, coding, testing, and documenting the program. It also discusses programming errors known as bugs, flowcharts as visual representations of program logic, escape sequences for cursor control, and basic data types in C. Additionally, it covers control structures such as sequence, selection, and iteration, along with specific programming constructs like if statements and switch cases.

Uploaded by

adsglowagency
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
8 views

computer long

The document outlines the steps in programming, which include defining the problem, planning the solution, coding, testing, and documenting the program. It also discusses programming errors known as bugs, flowcharts as visual representations of program logic, escape sequences for cursor control, and basic data types in C. Additionally, it covers control structures such as sequence, selection, and iteration, along with specific programming constructs like if statements and switch cases.

Uploaded by

adsglowagency
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
Q 03: Explain the steps in programming. 1) DEFINING THE PROBLEMS: : Itis impossible to develop a solution fo a pusble ityou! “dy not hav “n,cleaf understanding of the problem itself, The programmer's “eTirst task is, therefdge, to's Jetermine jst gt the problem is and how to solve it, Defining the problenrfequires that th J progammer specify Foy mini task. They are The progranituer’s objective * The deSited outpay + The‘inpusrlata required The fe peeing cequlrcigns 2) PL3NNING v1 THe SOLUTION: Once the pratiiammer has determined what the rograniroust do, the next step is to pla as. prgferablg using Shacturethprouramming techniqueSor pfogram design tools. These techn of thefollowing: ig The Professional Academy _=3__ The Professional © Top- -down prgerarit design © Algorithm = *s. ss * Flowchart - ” Es 3) CODING THE PROGRAM: When the solution has been planned and designed it needs to be implemented u language. This process is called coding. Accarding to requirement a reasonable programming language is selected to implement the solution. 4) TESTING THE PROGRAM: Once the program has been coded completely the next phase is the implementation. By the implantation the programmer comes to know the physical and logical errors which are supposed P debug. The program is tested rewarding all types of error that are syntax errors, logical eros 38 3. The Professional Academy Prepared by: SIR S.M.RIZWAN - oe YY me Professional Academ — time errors. The testing phase makes sure that the program fulfills all the objectives which are required 2 The Professional Academy The Professional Academy 3 The Professional Academy for the users. 5) DOCUMENTING THE PROGRAM: Documentation is a written detailed description of the programming cycle and specific facts about the program. Typical program documentation materials include the origin and nature of the program, a brief narrative description of the program, algorithm and flowcharts, data-record descriptions, program listings, and testing results. Q 04: What is bug? Describe the types of programming errors with appropriate example. Programming errors are knows as bugs. }° Cominehts (‘and ‘}'are used for providirlg comnteyts or marks. £8, Géntrol Traysfer: Use ‘Goto Step n° to transfer geittrol to step a. The Profes Q4: What is flowchart? Drseribe'the functions of various flowcharting symbols and give their sa pictorial representation. ~~ ‘ 3 FLOWCHARTS: ‘ef A flowchart is a pictorial representation of logic used in a computer program. It illustrates the major program elements and how they are logical integrated. The symbols used in flowchart are given below: Terminal Symbol: The terminal symbol is used to indicate the beginning (START), ending (STOP), and pauses (HALT) in the program logic flow. It is the first symbol and the last symbol in the program logic. In addition, if the program logic calls ~ fora pause in the program, that also is indicated with a terminal symbol. The Professional Academy Bim it Prepared By Sir Rizwan Chapter No 02; Page? { (SK The Professional Academy BR, The Professional Academy MB. The Professional Academy list -2(tpevontoet Seabee = 3 : 4|| |] meinravougu symbol is se to denote any typeof np di or output all information. This symbol represents generic inputoutput functions ofall . & q (@aratielogram) site . E || | &| Process Symbol: g | 4 proces symbol is used ina flowchart to represent an operation involved in 5 | | [ge estual processing of data. The process symbolised for all arithmetic and data |Z transfer (MOVE) operations. Z| 3 Sfrnowtmes: iz i Flow ies with arowheads are usd adits thew of opera, tis, “S| 0 LL |} | | teeract sequence in which the isttions arto be executed. The normal = = Fe 3 low of tower fom opto boom nd I tog A S|} 3 eye ig lof ls The decision symbols used ir owt to indicate afoint.t which a deeiion. * iz gins bemadnsnd aback te of tuo or more aliématiyé points is posits 3 (Diamond 31] | S| OnPae Com iz ||| 3 3 ita fowesaiey becorites very long, the Aowlinge tat efessing at many places that S|! | S| causes confusion and retiyces understandability ofthe flowchart. In this situation it ati |e is yxéful ty-Gilize the consisetor symbol as a substituts for Séwlines. This symbol 8 + | | reptesenis an eatry-frdm, or aivexit to another part ofthe flowchart. (Cirete > fF] g i be 2] This symbol is used to connect pats Df4fe lowebart from one page to another. g | [3 Z| | 3|Bredetined Process Symbol: Se | Sle i , 3} | 3] This symbols used to access (“peform” or “call” a subroutine not detailed ofthat 2 $ Particular point but usually define d in a separate micro flowchart. May be either S| | &| procedures or functions that are used epentedly or stops that would overly S| | 8] complicate tue nowebart. a | jaf mseutionSembot an 3 2 ee Prepared By Sir izwan Chapter No 02; Page 3 Awapedy jeuojssajoig oy, FE _Maropeay reuoissajorg oy “SF Awapesy reuoyssayorg ay = ‘Auppeay [euaIssajoig 24) Be The Professional Academy $2 The Professional Academy 2% The Professional Academy 8. The P Q 10: What are Escape sequences? Mention all Eseape sequences. ESCAPE SEQUENCES Escape sequences are the special codes which are used to control the way the cursor moves on monitor. An escape sequence consists of the escape character and a second character. Though there are two characters in an escape sequence they are cosared as a single character. Some of them are shown in the following table. ¢ = ESCAPE SEQUENCE MEANING RESULT A AT EXECUTING SIME Movesuthe bursef at t she beginning. oF fa ny ce Oats |e neat linea It Tie loves the*gursdy to the next tab stop. la | Alett f/f Produces a baep Moves the active position to the initial * position of the next paragraph. Moves the active position to previous eee position on the current line. Float Data type: ‘The float data type,éprespnts floating, point yélues, rieaning any singed or unsigned number having a decimal point. Examples of valid float are: “ 2778294 39520578 495.0 “4493. Flogt cp be single'o¢ double precision. So, double iS s6d to store decimal numbers (numbers with = Furopeay 1eu01ss9j01d OUL Fusapeay 1eu01ss9j02d UL floating point value) Batwith dquble precision. Examples of double are: 98.74563 2.73e+03 “S3.14B3_ 5884261 4: What are constants? Describe the different type of ‘constants. Tjeuoissajord UL = The Professic ZA, The Professional Academy 3X The Professional Academy 28, The Professional Academy i sub-program or functions, it also makes programs easier, to write, CeCK, 1eau aus mavusy, Q2: What are control structures? Define them. CONTROL STRUCTURE Control Structures control the flow of execution in a program or function. Structure programming ., a limited number of control structures. There are three basic conto structures in structure programing: 1, Sequence, or sequential flow 2. Selection, or conditional flow 3. Iteration, or repetitive flow THE SEQUENCE CONTROL STRUCTURE which they appear within the prograp” as THE SELECTIONS contRet. spxticrure ‘The selections control structire catfloys auumber ot conditions which lead to selection of one or of several. altematives. CE groves thide | types of dlectiga: structures. eo The if selection stfucture ™ e Ifelse,sélectipa structure a Ths Swit ig Selection structure THE TFERATIVE CONTROL STRUCT! ‘URES The confiertich eter ‘tq repetition. Inprogramiig yhen a statement or number of statements ¢ suppaséd to be repeated for specified number of tinies. It is done by the iterative control structure: There are three iterative control structures used in C language. 1. For loop 2. While loop 3. Dowhile loop Q3: Define if statement in C. ‘THE IF SELECTION STRUCTURE ‘The if statement tests a particular condition. Whenever that condition evaluates as true, an action is perfonned—but if it is not true, then the action is skipped and control transfers to the next step of the program. ichure of the command is: The general su ift (condition) Prepared by: SIR S.M.RIZWAN - (Kil Computer; Chapter No 07) Page 20° re t [Be The Proessional academy The Professional Academy 2. The Professional Academy Statement; : my (4: How can we perform multiple statements when the condition Is (rue? ‘MULTIPLE STATEMENTS ‘The basic if command performs one statement. If you want to perforin more than one statement when the condition is true, you must use a second level of branches. The braces mark the beginning and end ‘of block of statements performed when the condition is true: iffcondition) { statement 1; statement 2; statement 3: d (Q5: Define Nested if statement. ‘NESTED IF STATEMENTS An if condition can be wrt as ply as you edith the body of ape’ sttement Thisis called nesting ofif's. Fr eximuple alracion is pertOnmesif two conditions aretine. The condition | is QB+Define if else sélgct stugture. ‘THE IF-ELSE SELECTIONS STRUCTURE, Ifelse selection structure perfolms cetfain action when the condition is true and some different action when the conditions false. “S-” ‘The general stmoture ofthe command is: if{condition) statement 1; else statement 2; QT: Define Nested ifelse statements, “EE The Professional Academy S&_The Professional Academy 8. The Professional Academy SE The Professional Acade Taapeay RuorIOd ou ER AuaPEV euoRTajoIg oul ER’ AupeviewoRsoad a “ER AUPE UOT Au EE Prepared by: SIRS M.RIZWAN ‘The Professional Academy The Professional Academy NESTED IF-ELSE STATEMENTS i Nested if-else stotements fst for multiple conditions by placing iFelse statements inside ifelse statements, When a conditions evaluated as tru, the coresponding statements are executed andy ‘rest of structure is skipped. This structure is referred to as the if-else-if ladder. sample Program: ‘include #includeceoaio.h> ‘void unain(void) it cclrser(); int month; rintf{“Input month number: "); seanf('%d", Samoath iffeoonth = 1) printf("January"); else iffmonth—=2) rintf(“February"); else iffmonth = 3) else if{month = 4) ripe The Professional Academy OE The Professional Academy Ba The Professional Academy rin else iffonth = 10) rnt(“October); tse ion — 11) print{("November”); clse iffmouth = 12) print{(“December"); ritf(“error in month numbe!t"); getehd } The Professional Acadehmy SE & The Professional Acadern The Professional Academy tre essional Academy 38. The Professional Academy Q8: Define switch caso statement with syntax, ‘THE SWITCH STATEMENT ‘The switch statement is used to select one of the several alternatives, such as menu options. The Switch statement is especially usefull when the selection is based on the Value ofa single variable called controlling variable) or of a simple expression (called the controlling expression). The value of this variable may be of type int or char, but not of type float, the switch statement also differs form if, in that switch can only test for equality, whereas the if conditional expression can be of any type. The general form of the switch statement is: Syntax: switch( variable) case constant 1: statement(s); break; case constant 2: statement(s); break; case constant 3: statement(s); Ausapeay [eu0|ssajold BUL = Aurapeay |euojsspicld AUL Q9: Diftaventiate between switch and ifebse, ss0jold UL Se my “BE The Professional Academy _3k__The Professional Academy _S& The Professional Academy SS. ‘The Professional Acade Tz Thefts acadery zg The Profesional cade Ri The Pofsona Aeadery (4: Explain for Toop with syntax and example program. . . FORLOOP Tn C language the most commonly used iterative control structure is “for” loop. Which is used to repeat a statement or block of statements for a specific number of times. Syntax For initialize expression; test expression; incrementlectement expression) { ‘Statements(s); } Explanati ‘The “forloop” includes three expressions in the parenthesis ‘he initializecexpression tells the compiler the starting value from where the loop is going to bt staited. The test tagressions specifies the last Limit until the iteration has to be performed. The incretkent br dectement bring the started ‘value across the test expression. After the parenthesis the’ brackits { include eee orPblock of | ‘statements to be repeated. Example: ‘void main( ) ( - int a; UCounstr Varitble clrser( ); ‘s, for (a=; acel0, at), t U[Blockoftegp _printe( Welcome \n" Flowchart format of for loon ‘ranared by. SIR SM.RIZWAN TKil Computer, Chapter Noa) Page 3of& Taapeay jeuomtayeig su EE Auspesy eusisojoNd ou “ER Auepeay wionsioa al “EE Auanay wuORmO A EE Be therofessional Academy SR The Profesional Academy 2 The Professional a oh" = ele (Q5: Explain Whilé loop with syntax and example program, WHILE LOOP ‘While loop is an iterative control structure of C. Iti a contitional oop which is used to repeat a statement orblock of statements fora number of times depending on a condition. . Syntax ‘While (condition) { The Professional Academy Statements(s); bbe repeated onthe bases of some mentioned comition: Example Program: void main() { Int a=0; clescet); while(a

You might also like