.

Tuesday, April 2, 2019

Programming Languages: Types and Uses

platformming Languages oddballs and Uses1. IntroductionC Programming is a computing device diction that is structured and discip marged approach to class design. Its a good systems scheduling terminology. This is faster than java, more predictable practiceance and it has pitiable level operations and it has a lot scope for bugs.This C scheduleming has no Boolean type . It is employmentd by victimisation int err case-by-caseous is zero and true is non-zeroA simple C chopineint main()Text contact by /* and */ is ignored by computer and it is used to describe the curriculum embarrass Pre fermentor directive tells the computer to load contents of a authoritative file altogetherows standard input/output operationsC++ course of instructions sort out out one or more manoeuvres, studyly one of which must be main and P atomic numerate 18nthesis is used to indicate a function . int inwardness that main returns an whole number value and braces indicate a block.The bod ies of all functions must be contained in braces . mugf( Welcome to Cn )Instructs computer to perform an action specifically and prints string of pillowcases within quotes.Entire line is called a statement. totally statements must end with a semicolon.- means wetting character. Indicates that printf should do something out of the ordinary.n is the newline characterreturn 0 A guidance to exit a function.return 0, in this case, means that the program complete prevalently .Right brace Indicates end of main has been reached.Linker When a function is called, linker locates it in the library and Inserts it into inclination program. If function name misspelled, linker will status mistake because it fundament non find function in library.CalculatorThis is use very frequently in anyday life by almost everyone .In this reckoner we bunghole only perform operations like accompaniment (+), subtraction (-), division (%), multiplication(*), only integer valued functions. We get imm aculate values too .2. Scientific CalculatorThis calculator wad perform all the operations that normal calculator can do and it can also perform the operations likeTrigonometry Sine, Cosine, Tangent, Inverse-1 Angles DEG, DMS, dateMemories M, K1, K2 Programs LRN, COMP, HLT, (x)3. C-Programming3.1 What is c- scheduling ?A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks . The term programming linguistic communication usually refers to high-ranking languages, such as BASIC, C, C++, COBOL, FORTRAN, Java, and Pascal. Each language has a ludicrous set of keywords (words that it understands) and a special syntax for organizing program instructions. Regardless of what language you use, you casingually need to convert your program into mechanism language so that the computer can understand it. There atomic number 18 two slip representation to do this compile the program , interpret the program .3.2 Programming plow3.2.1 Analyze the Prob lemA programmer must know what cultivation will go into the softwargon system program, how it will process the information, and what will result. All software must work with three concepts to be successfulInput randomness that comes from an external root system and enters the software an. Input can come from type on a keyboard, from records in a database, or from clicking on range with the mouse touch on Manages information according to a piece of softwares logical system. Processing is what the software does to the input it receives. This can be anything from adding a few total together to mapping the earths climate.Output The information software produces after it has affect input. Output can appear on a computer screen, in a printout, or in records in a database.3.2.2 Develop an algorithmic ruleAlgorithms are the steps needed to work on a problem using pseudo statute or flowcharts. After creating an algorithm, programmers will demote it. A logic error is a mistake in the way an algorithm solves a problem. Programmers check their algorithms by inputting test data and checking the logic by hand or with a calculator.3.2.3. Document the Program pseudo principlePseudocode uses English statements to create an outline of the needed steps for a piece of software to operate. Programmers call these steps an algorithm. An algorithm is a set of specific steps that solves a problem or carries out a task. While there is no set of rules for compose pseudocode, it usually follows rules such as Using simple English, Putting one verify on a line, Placing any important words in bold, Starting from the top and work toward the bottom, Separating processes with spaces to form modules.3.2.4 Write Code for the ProgramCode is when a programmer translates an algorithm into a programming language.3.2.5 conduct the ProgramProgrammers also use program flowcharts to plot the softwares algorithm. A program flowchart is a graphical depiction of the detailed steps that sof tware will perform. Unlike pseudocode, which has less structure, in flowcharts programmers must use symbols.3.2.6 testing the programsDebugging the process of finding errors in software code.Bugs are a putting surface name for software errors. When programmers debug code, they look for syntax, run-time, and logic errors.Syntax errors mistakes in a software codes grammar. If you are supposed to use a semi-colon () and you use a colon () instead, you have make a syntax error.Run-time errors mistakes that die when a programmer runs the software code .Logic errors mistake made in the way an algorithm solves a problem.4. Types of programming4.1 Object-oriented programmingObject-oriented programming (OOP) is any programming language that uses objects to code software. An object instance is an exact copy of an object in OOP. An event-driven language responds to actions users perform on the program.Its an event when you click on a button, use a pull-down menu, or roster down a wind ow. In an event-driven language, each event triggers the program to action.An OOP program models the world of active objects. An object may have its own memory, which may contain a nonher(prenominal) objects. An object has a set of methods that can process messages of certain types.A method can multifariousness the objects state, send messages to other objects, and create new objects. An object belongs to a particular class, and the functionality of each object is meetd by its class. A programmer creates an OOP application by delimit classes.4.2 The Main OOP ConceptsInheritance a subclass extends a superclass the objects of a subclass inherit features of the superclass and can redefine them or add new features.Event-driven programs the program simulates asynchronous manipulation of events methods are called automatically in response to events.OOP BenefitsFacilitates team development and Easier to employ software components and write reusable software. Easier GUI (Graphical Us er Interface) and multimedia programming .4.3 Web-programmingHyper Text Markup Language (HTML) is the basic language for web programming.JavaScript a scripting language that allows you to add interactivity and other features to a Web page.Java Applets A smallish piece of software that enables applications to run on a Web page. high-octane HTML combines cascading style sheets, JavaScript, etc., to bring high interactivity to Web sites.VBScript an interpreted scripting language based on Visual Basic. It is similar to JavaScript but only Microsofts net Explorer Web browser can use it.Software ontogenesis ToolsEditor programmer writes source code for te program. compiler translates the source into object code (instructions specific to a particular CPU).Linker converts one or several object modules into an executable program.Debugger stepping through the program in shadowy motion, helps find logical mistakes (bugs).5. ArrayGroup of consecutive memory locations and kindred name an d type To refer to an element, specifying Array name and Position compute format arraynameposition numberFirst element at position 0 and n element array named c c0, c1cn-1Array elements are like normal variantsc0 = 3printf( %d, c0 )Perform operations in subscript. If x = 3,c5-2 == c3 == cxWhen declaring arrays, specify Name, Type of array, Number of elementsarrayType arrayName numberOfElements int c 10 float myArray 3284 Declaring seven-fold arrays of same type and Format similar to regular variablesint b 100 , x 27 Examples Using ArraysInitializers int n5 = 1, 2, 3, 4, 5 If not enough initializers r there, rightmost elements become 0 and If too many an(prenominal) an(prenominal) are there then its a syntax error.int n5 = 0All elements is 0C arrays have no bounds checking andIf size is omitted, initializers determine it int n = 1, 2, 3, 4, 5 5 initializers, therefore 5 this iselement arrayCharacter arrays depict hello is really a static array of characters and Character arra ys can be initialized using string literalschar string1 = firstnull character terminates stringsstring1 actually has 6 elementschar string1 = f, i, r, s, t, Access individual characters string1 3 is character sArray name is address of array, so not needed for scanfscanf( %s, string2 ) Reads characters until whitespace en antipatheticed and Can write beyond end of arrays.5.1 Interpretation example = program that executes program statements and generally one line or command at a time for a limited processing and its on the loose(p) to debug, make changes, view intermediate results.5.2 Compilationtranslates statements into machine language and does not execute, but creates executable program to perform optimization over multiple statements in order to changing requires recompilation and it can be harder to debug, since executed code may be different.5.3 Compiling a C ProgramPreprocessor big substitution and conditional compilation of a source-level transformations and output is s till C.5.4 Compilergenerates object file from machine instructions.Source Code Analysis is a front end parses programs to identify its pieces variables, expressions, statements, functions, etc. depending on language (not on target machine).Code Generation is a back end generating machine code from analyzed source may optimize machine code to make it run more efficiently very dependent on target machine.Symbol Table map between symbolic label and items like assembler, but more kinds of information.5.5 Linkercombine object files (including libraries) into executable image.5.6 pick out ArraysSorting data is Important computing application and eventually every organization must sort some data into Massive amounts of screen out information.Bubble sort (sinking sort) has Several passes through the array and Successive pairs of elements are compared in order to increasing order (or identical ), no change is there If decreasing order is done and if elements exchanged.6. AlgorithmsThere are many fundamental problems that arise in engineering and other areas of application. These allow in sorting data, searching for specific data values, numerical integration, finding roots of functions, solution ordinary differential equations and solving systems of linear equations and We will spend almost four weeks studying important algorithms for these problems. Algorithms are the steps needed to solve a problem using pseudocode or flowcharts. After creating an algorithm and its programmers check its logic. A logic error is a mistake in the way an algorithm solves a problem. Programmers check their algorithms by inputting test data and checking the logic by hand or with a calculator.7. IDE Integrated Development surroundThe integrated development environment Combines editor, compiler, linker, debugger, other tools and Has GUI (graphical user interface), Compiles + cerebrate + runs at the click of a button Helps put together a project with several modules (source files) .C ompiler checks syntax and generates machine-code instructions so that its not needed to run the executable program to run faster . congressman checks syntax and executes appropriate instructions while interpreting the program statements and must remain installed while the program is interpreted so the interpreted program is slower.Platform independent . Load from the Internet faster than source code. representative is faster and smaller than it would be for Java source. Source code is not revealed to end users. Interpreter performs additional security checks, screens out malicious code.8. Preprocessor Directives implicate Before compiling, copy contents of header file (stdio.h)into source code. past Header files typically contain descriptions of functions andvariables needed by the program. no restrictions it could be any C source codedefine STOP 0Before compiling, it replaces all instances of the string STOP with the string 0 Called a macro and its Used for values that wont chan ge during execution,but business leader change if the program is reused. (Must recompile) .main FunctionEvery C program must have a function called main(). This is the code that is executed when the program is running. The code for the function lives within brackets.main() /* code goes here */Variable DeclarationsVariables are used as names for data items. And Each variable has a type,which tells the compiler how the data is to be interpreted (and how much space it needs, etc.).int counterint startPointint is a predefined integer type in C.Input and Output material body of I/O functions in C Standard Library. And must include to use them.printf(%dn, counter) attract contains characters to print and formatting directions for variables. This call says to print the variable counter as a ten-fold integer, followed by a linefeed (n).scanf(%d, startPoint)String contains formatting directions for looking at input. This call says to read a decimal integer and assign it to the variable st art Point .Can print arbitrary expressions, not just variablesprintf(%dn, startPoint counter)Print multiple expressions with a single statementprintf(%d %dn, counter,startPoint counter)Different formatting options%d decimal integer%x hexadecimal integer%c ASCII character%f floating-point numberExamples of C-Programming*Program to implement an arrayinclude include define scoop shovel 3 nihility stash away ( int *, int pos, int num ) void del ( int *, int pos ) void reverse ( int * ) void display ( int * ) void search ( int *, int num ) void main( )int arr3 clrscr( ) wrap ( arr, 1, 11 ) insert ( arr, 2, 12 ) insert ( arr, 3, 13 ) printf ( nElements of Array ) display ( arr ) insert ( arr, 2, 222 ) insert ( arr, 3, 333 ) printf ( nnAfter insertion ) getch( ) int i for ( i = MAX 1 i = pos i )arri = arri 1 arri = num int i for ( i = pos i arri 1 = arri arri 1 = 0 int i for ( i = 0 i int temp = arri arri = arrMAX 1 i arrMAX 1 i = temp int i for ( i = 0 i if ( arri == n um )printf ( nnThe element %d is present at %dth position., num, i + 1 ) return if ( i == MAX )printf ( nnThe element %d is not present in the array., num ) *Program to allocate memory dynamically for strings, and bloodline their addresses in array of pointers to stringsinclude include include include void main( )char *name5 char str20 int i clrscr( ) for ( i = 0 i printf ( Enter a String ) gets ( str ) namei = ( char * ) malloc ( strlen ( str ) + 1 ) strcpy ( namei, str ) printf ( nThe strings are ) for ( i = 0 i printf ( n%s, namei ) for ( i = 0 i free ( namei ) getch( ) 9. Conclusion and future workConclusionFinally the shutdown is that a small study on the C-programming and how it is used to built scientific calculator.Future workThe future work is that to implement scientific calculator based on the c-programming .

No comments:

Post a Comment