Monday, 31 October 2016

How to Install ,Run and Save Program in GW-Basic

Install ,Run and Save Program in GW-Basic 
GW-Basic  setup download to click 

Step to install

  1. Download to given address 
  2. Double click the file and extract it .
  3. run the exe file by double click 
  4. start coding  ..
  5. as show in above video .  

System Requirements in GWBasic

Welcome to GW-BASIC

Notational Conventions

Microsoft® GW-BASIC® is a simple, easy-to-learn, easy-to-use computer programming language with English-like statements and mathematical notations. With GW-BASIC you will be able to write both simple and complex programs to run on your computer. You will also be able to modify existing software that is written in GW-BASIC.


This guide is designed to help you use the GW-BASIC Interpreter with the MS-DOS® operating system.

1.1 System Requirements


This version of GW-BASIC requires MS-DOS version 3.2 or later.


1.2 Preliminaries


Your GW-BASIC files will be on the MS-DOS diskette located at the back of the MS-DOS User's Reference. Be sure to make a working copy of the diskette before you proceed.


Note:-

This manual is written for the user familiar with the MS-DOS operating system. For more information on MS-DOS, refer to the Microsoft MS-DOS 3.2 User's Guide and User's Reference.


1.3 Notational Conventions



Throughout this manual, the following conventions are used to distinguish elements of text:


Used for commands, options, switches, and literal portions of syntax that must appear exactly as shown.


Used for filenames, variables, and placeholders that represent the type of text to be entered by the user.


Used for sample command lines, program code and examples, and sample sessions.


Used for keys, key sequences, and acronyms.


Brackets surround optional command-line elements.


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.

Wednesday, 26 October 2016

Pointers in C Programming

Pointers
Pointers in C are easy and fun to learn. Some C programming tasks are performed more easily with pointers, and other tasks, such as dynamic memory allocation, cannot be performed without using pointers. So it becomes necessary to learn pointers to become a perfect C programmer.
every variable is a memory location and every memory location has its address defined which can be accessed using ampersand (&) operator, which denotes an address in memory.
A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address.

pointer declarations:- 

How to used pointers:-  
which we will do with the help of pointers very frequently. (a) We define a pointer variable, (b) assign the address of a variable to a pointer, and (c) finally access the value at the address available in the pointer variable. This is done by using unary operator * that returns the value of the variable located at the address specified by its operand.
Null pointer:- 
A pointer that is assigned NULL is called a null pointer.

The NULL pointer is a constant with a value of zero defined in several standard libraries.
a null pointer, you can use an ‘if’ statement
Pointers in detail 

Tuesday, 25 October 2016

Passing Arrays to Function in C Programming

Passing Arrays to Function 

To pass a single-dimension array as an argument in a function, you would have to declare a formal parameter in one of following three ways. 
 1st method  Formal parameters as a pointer
2nd method  Formal parameters as a sized array
3rd method Formal parameters as an unsized array
Example :- 

Return Arrays from to Function 

C programming does not allow to return an entire array as an argument to a function.However, you can return a pointer to an array by specifying the array's name without an index.


 Example :-
 
Pointer to a Array 
An array name is a constant pointer to the first element of the array.

 balance is a pointer to &balance[0], which is the address of the first element of the array balance. Thus, the following program fragment assigns p as the address of the first element of balance
Example :- Once you store the address of the first element in ‘p’, you can access the array elements using *p, *(p+1), *(p+2), and so on.
 

Arrays Types in C Programming

Arrays are important to C and should need a lot more attention.

Multidimensional Arrays

C programming language allows multidimensional arrays.
Example:- 

Two-Dimensional Array

The simplest form of multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a list of one-dimensional arrays.
A two-dimensional array a, which contains three rows and four columns.

Initialized Two-Dimensional Array 

Multidimensional arrays may be initialized by specifying bracketed values for each row.
The nested braces, which indicate the intended row, are optional.

Accessed Two-Dimensional Array Elements 

An element in a two-dimensional array is accessed by using the subscripts, i.e., row index and column index of the array.
Example :- 
 

Tuesday, 11 October 2016

Arrays in C Programming part 11 a

Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
               Declaring individual variables, such as number0, number1, ..., and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables. A specific element in an array is accessed by an index.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.

Declare an array

Declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array
 This is called a single-dimensional array. The arraySize must be an integer constant greater than zero and type can be any valid C data type. For example, to declare a 10-element array called balance of type double

Initialize an array

Initialize an array in C either one by one or using a single statement
 The number of values between braces { } cannot be larger than the number of elements that we declare for the array between square brackets [ ].

Accessed by indexing

Accessed by indexing the array name. This is done by placing the index of the element within square brackets after the name of the array.
     

Variable Scope in C Programming

A scope in any programming is a region of the program where a defined variable can have its existence and beyond that variable it cannot be accessed.


  • Inside a function or a block which is called local variables,
  • Outside of all functions which is called global variables.
  • In the definition of function parameters which are called formal parameters.

Local Variable 

Variables that are declared inside a function or block are called local variables. They can be used only by statements that are inside that function or block of code. Local variables are not known to functions outside their own.

Global variables



Global variables are defined outside a function, usually on top of the program. Global variables hold their values throughout the lifetime of your program and they can be accessed inside any of the functions defined for the program.
A global variable can be accessed by any function. That is, a global variable is available for use throughout your entire program after its declaration.

Formal parameters

Formal parameters are treated as local variables with-in a function and they take precedence over global variables.

 

 initialized  Local and Global Variables

When a local variable is defined, it is not initialized by the system, you must initialize it yourself. Global variables are initialized automatically by the system when you define them.

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.