Showing posts with label high level language. Show all posts
Showing posts with label high level language. Show all posts

Sunday, 30 October 2016

GWBASIC Introduction Programming

GWBASIC a good start-easy to learn, portable executable program  with graphics capability, and is a freeware.
–BASIC-acronym for Beginners All-purpose Symbolic Instruction Code
•designed as a language for beginners
•developed by John Kemeny and Kenneth Kurtz
•GWBASIC-version of BASIC produced by Microsoft,Inc.

Gwbasic, Fortran and other higher level languages do essentially the same thing-they interpret the program or souce code we write into a language the machine can understand.
Gwbasic is a program by itself.
It is an interpreter, that is, it translates our code line by line to the computer while our program is running.

Gwbasic screen; KEY OFF, KEY ON
•Coding or writing a new program (NEW)
•Saving a program (SAVE or  F4 key)
•Loading or recalling a program (LOAD or F3 key)
•Running a program (RUN or F2 key)
•Ending your computer session (SYSTEM)
•NEW
•SAVE “filename”
•LOAD “filename”
•RUN “filename”
•SYSTEM
•Note: close quotation optional. Extension name if not present is understood to be .BAS.

Tuesday, 4 October 2016

Function Types in C Programming

                  A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions.
                 You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but logically the division is such that each function performs a specific task.

Defining Function 

Here are all the parts of a function:

 Return Type: A function may return a value. The return_type is the data type of the value the function returns. Some functions perform the desired operations without returning a value. In this case, the return_type is the keyword void.
 Function Name: This is the actual name of the function. The function name and the parameter list together constitute the function signature.
Parameters: A parameter is like a placeholder. When a function is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a function. Parameters are optional; that is, a function may contain no parameters.
Function Body: The function body contains a collection of statements that define what the function does. 



Function Declaration

A function declaration tells the compiler about a function name and how to call the function. The actual body of the function can be defined separately.
A function declaration has the following parts:


For the above defined function max(),the function declaration is as follows:


Parameter names are not important in function declaration, only their type is required, so the following is also a valid declaration:

 Call a Function

When a program calls a function, the program control is transferred to the called function. A called function performs a defined task and when its return statement is executed or when its function-ending closing brace is reached, it returns the program control back to the main program.

Function Arguments

If a function is to use arguments, it must declare variables that accept the values of the arguments. These variables are called the formal parameters of the function.
Formal parameters behave like other local variables inside the function and are created upon entry into the function and destroyed upon exit.

Call by Value

The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
                 C programming uses call by value to pass arguments. In general, it means the code within a function cannot alter the arguments used to call the function. Consider the function swap(),

 Call by Reference

The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. It means the changes made to the parameter affect the passed argument.
To pass a value by reference, argument pointers are passed to the functions just like any other value. So accordingly, you need to declare the function parameters as pointer types as in the following function swap(), which exchanges the values of the two integer variables pointed to, by their arguments.
 


Saturday, 1 October 2016

Loop Control Statements in C Programming

Loop Control Statements  

Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.

The break statement in C programming has the following two usages:

  • When a break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop.
  • It can be used to terminate a case in the switch statement.

If you are using nested loops, the break statement will stop the execution of the innermost loop and start executing the next line of code after the block.

Syntax
 Flow chart
 Example
Continue Statement

The continue statement in C programming works somewhat like the break statement.
Instead of forcing termination, it forces the next iteration of the loop to take place,skipping any code in between.

For the for loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while and do...while loops, continue statement causes the program control to pass to the conditional tests.

Syntax 
 Flow chart

Goto statements:-

A goto statement in C programming provides an unconditional jump from the ‘goto’ to a labeled statement in the same function.

Syntax

Infinite loop

A loop becomes an infinite loop if a condition never becomes false. The for loop is traditionally used for this purpose. Since none of the three expressions that form the ‘for’ loop are required, you can make an endless loop by leaving the conditional expression empty. 
 

Thursday, 22 September 2016

Decision making in C Programming

C  programming  language  assumes  any non-zero and non-null values  as true, and if it is  either zero or null, then it is assumed as false value.C  programming  language  provides  the  following  types  of  decision-making statements.

  •   if Statement 

An if statement  consists  of  a  Boolean  expression  followed  by  one  or  more statements.









  • if…else Statement 

An if statement  can  be  followed  by  an  optional else statement, which  executes when the Boolean expression is false.
Syntax 
The syntax of an if...else statement in C programming language is:





  •  if...else if...else Statement 

An if statement can be followed by an optional else  if...else statement, which is very useful to test various conditions using single if...else if statement.
Syntax 

  •  Nested if Statements 

It is always legal in C programming to nest if-else statements, which means you can use one if or else if statement inside another if or else if statement(s).
Syntax 
The syntax for a nested if statement is as follows:

                              

  •  Switch Statement 

A switch statement allows a variable  to be  tested  for equality against a  list of values.  Each  value  is  called  a  case,  and  the  variable  being  switched  on  is checked for each switch case.
Syntax 
The syntax for a switch statement in C programming language is as follows:









Wednesday, 14 September 2016

Operator Types in C Programming

An operator is a symbol that tells the compiler to perform specific mathematical or  logical functions.  C  language  is  rich  in  built-in  operators  and  provides  the following types of operators: 

  •   Arithmetic Operators 
  •   Relational Operators 
  •   Logical Operators 
  •   Bitwise Operators 
  •   Assignment Operators 
  •   Misc Operators 


 Relational Operators