Tuesday, June 4, 2019

Programming Languages: Types and Uses

Programming Languages Types and Uses1. IntroductionC Programming is a reck singler language that is structured and discip government noted approach to program design. Its a good systems programming language. This is high-velocity than java, more predictable performance and it has low level trading operations and it has a lot scope for bugs.This C programming has no Boolean type . It is used by apply int false is zero and true is non-zeroA simple C programint main()Text surrounded by /* and */ is ignored by calculator and it is used to describe the program imply Preprocessor directive tells the computing machine to clog contents of a certain file allows standard input/output operationsC++ programs contain one or more functions, exactly one of which mustiness be main and P atomic number 18nthesis is used to indicate a function . int means that main returns an whole number value and braces indicate a block.The bodies of all functions must be contained in braces .printf( Welcome to Cn )Instructs computer to perform an action specifically and prints string of set fire toacters within quotes.Entire line is called a statement. All statements must end with a semicolon.- means escape character. Indicates that printf should do something out of the ordinary.n is the newline characterreturn 0 A appearance to buy the farm a function.return 0, in this case, means that the program terminated normally .Right brace Indicates end of main has been r separatelyed.Linker When a function is called, linker locates it in the subroutine library and Inserts it into object program. If function name misspelled, linker will spot error because it nookienot find function in library.CalculatorThis is use very frequently in chance(a) life by almost everyone .In this calculator we nookie only perform operations like addition (+), subtraction (-), division (%), multiplication(*), only integer valued functions. We get accurate values too .2. Scientific CalculatorThis calculator t ush 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, TimeMemories M, K1, K2 Programs LRN, COMP, HLT, (x)3. C-Programming3.1 What is c- programming ?A vocabulary and rear of grammatical rules for instructing a computer to perform specific tasks . The term programming language usually refers to high-level languages, such as BASIC, C, C++, COBOL, FORTRAN, Java, and Pascal. Each language has a comical set of keywords (words that it understands) and a special syntax for organizing program instructions. Regardless of what language you use, you in the end need to convert your program into machine language so that the computer can understand it. There are two ways to do this compile the program , interpret the program .3.2 Programming process3.2.1 Analyze the jobA programmer must know what information will go into the computer software, how it will process the information, and what will result. All software must work with park chord concepts to be successfulInput Information that comes from an external citation and enters the software an. Input can come from typing on a keyboard, from records in a database, or from clicking on image with the mouseProcessing Manages information according to a piece of softwares logic. Processing is what the software does to the input it receives. This can be each(prenominal)thing from adding a few numbers together to mapping the earths climate.Output The information software produces after it has processed input. Output can appear on a computer screen, in a printout, or in records in a database.3.2.2 Develop an AlgorithmAlgorithms are the go needed to solve a problem development pseudo engrave or flowcharts. After creating an algorithm, programmers will check 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 b y hand or with a calculator.3.2.3. Document the Program pseudocodePseudocode uses English statements to create an outline of the necessary 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. go there is no set of rules for writing pseudocode, it usually follows rules such as Using simple English, Putting one command 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 Run the ProgramProgrammers also use program flowcharts to plot the softwares algorithm. A program flowchart is a graphical depiction of the detailed steps that software will perform. Unlike pseudocode, which has less structure, in flowcharts programmers must use symbols.3.2.6 Testing the programs Debugging the process of finding errors in software code.Bugs are a common 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 pretend made a syntax error.Run-time errors mistakes that occur 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 reduplicate 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 scroll down a window. In an event-driven language, each event triggers the program to action.An OOP program models the world of active objects. An obje ct whitethorn have its own repositing, which may contain other(a) objects. An object has a set of methods that can process messages of certain types.A method can change the objects state, send messages to other objects, and create new objects. An object belongs to a extra class, and the functionality of each object is determined by its class. A programmer creates an OOP application by defining 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 handling of events methods are called automatically in response to events.OOP BenefitsFacilitates team development and Easier to reuse software components and write reusable software. Easier graphical user interface (Graphical User Interface) and multimedia programming .4.3 Web-programmingHyper Text Markup Language (HTML) is the basic language for web progra mming.JavaScript a scripting language that allows you to add interactivity and other features to a Web page.Java Applets A small piece of software that enables applications to run on a Web page.Dynamic HTML combines cascading style sheets, JavaScript, etc., to choose high interactivity to Web sites.VBScript an interpreted scripting language based on Visual Basic. It is similar to JavaScript but only Microsofts Internet Explorer Web browser can use it.Software Development 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 slow motion, helps find logical mistakes (bugs).5. ArrayGroup of consecutive memory locations and Same name and type To refer to an element, specifying Array name and Position numberFormat arraynameposition numberFirst element at position 0 and n elemen t array named c c0, c1cn-1Array elements are like normal unsettledsc0 = 3printf( %d, c0 )Perform operations in subscript. If x = 3,c5-2 == c3 == cxWhen declaring arrays, specify Name, Type of array, exit of elementsarrayType arrayName numberOfElements int c 10 float myArray 3284 Declaring multiple 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 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 arraysString hello is really a motionless array of characters and Character arrays can be initialized using string literalschar string1 = firstnull character terminates stringsstring1 actually has 6 elementschar string1 = f, i, r, s, t, entrance fee in dividual characters string1 3 is character sArray name is address of array, so not needed for scanfscanf( %s, string2 ) Reads characters until whitespace en precludeed and Can write beyond end of arrays.5.1 explanationinterpreter = program that executes program statements and generally one line or command at a time for a limited processing and its flaccid 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 macro substitution and conditional compilation of a source-level transformations and output is still C.5.4 Compilergenerates object file from machine instructions.Source Code Analysis is a front end parses programs to severalise 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 amid symbolic names and items like assembler, but more kinds of information.5.5 Linkercombine object files (including libraries) into executable image.5.6 Sorting ArraysSorting data is Important computing application and eventually every organization must sort some data into Massive amounts of sorted 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 inherent problems that arise in engineering and other areas of application. These include sorting data, searching for specific data values, numerical integration, finding roots of functions, solving ordinary first derivative equations and solving systems of linear equations and We will spend about 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 EnvironmentThe integrated development environment Combines editor, compiler, linker, debugger, other tools and Has GUI (graphical user interface), Compiles + links + runs at the click of a button Helps put together a project with several modules (source files) .Compiler checks syntax and generates machine-code instructions so that its not needed to run the executable program to run faster .Interpreter checks syntax and executes appropriate instruction s 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. Interpreter 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 Directivesinclude Before compiling, copy contents of header file (stdio.h)into source code. Then 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 usage change during execution,but might 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 classification of I/O functions in C Standard Library. And must include to use them.printf(%dn, counter)String contains characters to print and formatting directions for variables. This call says to print the variable counter as a decimal 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 destine it to the variable start Point .Can print arbitrary expressions, not just variablesprintf(%dn, startPoint counter)Print multiple expressions with a single statementprintf(%d %dn, counter,startPoint counter) disparate formatting op tions%d decimal integer%x hexadecimal integer%c ASCII character%f floating-point numberExamples of C-Programming*Program to implement an arrayinclude include define MAX 3void salt 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( ) insert ( 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 == num )printf ( nnThe element %d is afford 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 store 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 conclusion 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

Note: Only a member of this blog may post a comment.