-->

Sunday, February 22, 2015

Successors of C language

C and even B have several direct descendants, through they do not rival pascal. One side branch developed early. When Steven Johnson visited the University of Waterloo on sabbatical in 1972, he brought B with him. It became popular on the Honeywell machines there, and later spawned Eh and Zed (the Canadian answers to 'what follows B?'). When Johnson returned to Bell Labs in 1973, he was disconcerted to find the language whose seeds he brought to Canada had evolved back home; even his own yacc program had been rewritten in C, by Alan Snyder.

More recent descendants of C proper include Concurrent C, Objective C, C* and especially C++. The language is also widely used as an intermediate representation (essentially, as a portable assembly language) for a wide variety of compilers, both for direct descendants like C++, and independent languages like Modula 3 and Eiffel. 

Saturday, February 21, 2015

C Language standards

C came into existence in between 1969-1973 in parallel with the development of UNIX operating system. The C Programming Language, in the middle of 1980s,was officially standardized by the ANSI X3J11 committee. Until the early 1980s, the language was almost exclusively associated with UNIX. Now, its use has spread much more widely, and today it is among the languages most commonly used in the industry.

BCPL the origination for C language was designed by Martin Richard in the mid-1960s and used during the early 1970s for several projects including OS6 operating system at OXford. The original BCPL compiler was transported both to Multics and to the GE-635 GECOS system by Rudd Canaday and others at Bell Labs. It was the language of choice among the group of people who involved with UNIX.

BCPL, B, and C all fit firmly in the traditional procedural family characterized by Fortan and Algo60. They are particularly oriented towards system programming. They are close to the machine. BCPL, B and C differ syntactically in many details, but broadly they are similar. Programs consist of a sequence of global declarations and function declarations. Several syntactic and lexical mechanism of BCPL are more elegent and regular than those of B and C. In spite of the differences , most of the statements and operators of BCPL map directly into corresponding B and C.

During the 1980s the use of the C language spread widely, and compiler became available on nearly every machine architecture and operating system; in particular it became popular as a programming tool for personal computers, both for manufactures of commercial software for these machine, and for end-users interested in programming.

Features of C Language

Definition: The capabilities and functionality provided by the C language are collectively called features of C Language. The features of C Language have made it popular.

Let us see, "What are the features of C language ?"

The C Language being a middle level language has many important features. It is said to be middle level language because of the following features:


  • The C language has the capabilities of assembly Language (Low Level Language)
  • It provide the functionality of a High Level Language.

As it is near to machine as well as to the user it is called middle level language. The capabilities of the low level language of C help in designing the program
especially required system management. It means the system software can be developed very easily using the C Language.

As It is also near to the user, most general purpose programs can be developed easily. So, the application programs can also be developed using C language.

In addition to the above mentioned features, C Language also has the following features:


  • Implementation of modular programming technique is very easy in case of C language because of the easy designing and handling of modules in the form of functions.
  • Each and every task using C Language is solved by means of function only so, C is called as functional language.
  • Users can define their own tasks in the form of user defined functions.
  • It has large collection of built-in or library functions that makes the programming task easier.
  • More and more user defined functions can be added to the library of the C to make the programs extendable.
  • C language is rich in operators containing very common arithmetic operators to system level bit-wise operators.
  • The programs written using C language are portable and can be executed at different platform.
  • C is a case sensitive language. All the keywords, data type means and built-in function names are written only using lower-case letters.
  • Most importantly the debugging, testing and maintenance activities of programs development can be performed easily on the program developed using C Language.
  • Implementation of structured programming technique is easy here because of the rich availability of the sequential, branching and looping structures.

How to use ComboBox in windows forms application c#

ComboBox in windows forms application -Introduction

A ComboBox display a editable TextBox with ListBox. You can select item from the list also you can search item by using TextBox. The default style of ComboBox is drop-down list. You can change the style of ComboBox with the help of DropDownStyle property. That property contain three enumerated value, If you select Dropdown list box then you can not edit text portion. Now, take a simple example to add items in the Combo Box-please see the video



Video contains different ways to add item in the ComboBox like, using show smart tag, items property, add item at run time using add method.
For adding items at run time in ComboBox:
 comboBox1.Items.Add(String text);
If you want to change the DropdownStyle at design as well as run time- please see the following video:


I you want to access or retrieve selected item from the comboBox then see this video. In this video i have a comboBox with some fruit items and a button control. When we press the button then selected item show in the messageBox.
Note : If you have to press buton without select any item then get the error message. Video also solve this problem with the help of selectedIndex property. So in this video you will see the example of SelectedIndex property.

 Now, come to the DataSource property of comboBox. Bind the combobox with the class and enumeration type. Video contain example of both type.


If you want to add thousand of item without any intrupt then use beginUpdate() and EndUpdate() method of it. This video contain example of both, also contain findString method example.

Friday, February 20, 2015

Pointer values in C language

Suppose, we have the following declaration:

int i=100, j=200, k=300;

This declaration tells the compiler to perform the following activities:

  • Reserve space for three integer values in memory.
  • Associate the variables i,j and k with these memory location.
  • Store 100,200 and 300 at the locations i,j and k respectively as shown as below:

Variable
Address
Memory Locations

0



2



4
100
I
……..
200
J
65534
300
K



variables
address
Values



The address of the variable cannot be accessed directly. The address of the variable can be obtained using address operator (& in C) .

Note : The address operator can be used with any variable that can be placed on the left side of an assignment operator.Since constants, expressions and array names can not be used on the left hand side of the assignment, and hence accessing address is invalid for constants, expressions and array names. The following are invalid:


Usage
Valid/Invalid
Reasons for invalidity
&100
Invalid
Address of a constant cannot be obtained.
&(p+100)
Invalid
Address of an expression cannot be obtained.
&(p+q)

Invalid
Address of an expression cannot be obtained.
Int a[10];
&a;
Invalid
Address of entire array cannot be obtained.
Register a;
&a;
Invalid
Address of a register variable cannot be obtained.

Note : if a is an array , then address of the first location of the array is obtained either using : &a[0] or a.

Assume that the compiler has chosen the address 65530 for the variable i, the address 65532 for the variable j and 65534 for the variable k. These address assigned to variables i,j and k are called pointer values.

Definition : Memory is divided into number of storage cells called locations. All the locations in computer memory are numbered sequentially from 0 to 65535 ( with memory size of 64k) . Out of these address, the system assigns some addresses of the memory locations to the variables. These memory addresses assigned to variables by the system are called pointer values. 

Thursday, February 19, 2015

Array in C language

Introduction

In this chapter, we will discuss a very important data type arrays. Let us see, “Why arrays?’’
We know that in one variable we can store the information of only one  data item. Suppose that a
Student has scored 90 marks. These marks can be stored in a variable as shown below:

int marks=90;

After executing this statement, the value 90 will be stored in the variable marks. Suppose there is
A need to store marks of 10 students. In such case, we are forced to use 10 variables like marksl,
Marks2… marks10. But, if it is required to store the marks of 100 students, definitely it is not
Feasible to use 100 variables marksl ,marks2…marks100, Now, the question is “How to store 100
different marks?” In mathematics, we use sets to group the items of similar kind, For example,
consider the set shown below :

marks = {80,90,45,99,100,36,88,96,67,92}

This is a set of marks of `10 students. Note that every item can be accessed by prefixing marks along
With the position of marks in the set. The first item 80 corresponds to the marks of first student,90
Corresponds to the marks of second student and so on i.e., marks1=80, marks2=90…marks 10=92.
In C language, this is where, the concept of arrays is used. Since all the marks are of the same type,
We can group and refer all the marks  with a common name using arrays.
Note: In general, if more number of data items of same type (kind) are to be accessed or read
or stored, then we use arrays.


The meaning of an array

Definition : An array is defined as an ordered set of similar data items. All the data items of
an array are stored in consecutive memory locations in main memory . The elements of an array
are of same data type and each item can be accessed using the same name. e.g. consider an
array of marks of 5 students as shown below:

80
90
45
99
100
Marks(0)
Marks(1)
Marks(2)
Marks(3)
Marks(4)

To refer an item in the array, we specify the name of the array along with position of the item. The
Position of the item must be written within square brackets ‘ []’.  The position of the item, The item enclosed within square brackets is called ‘subscript’ or ‘index’.

For example, the above figure represents an integer array called marks where marks of 5 students
Are stored. The marks of each student can be accessed as shown below:

       marks[0] i.e. 80 – represent marks of first student
       marks[ 1] i.e. 90- represent marks of second student
       marks[2] i.e. 45- represent marks of third student
      marks [3] i.e. 99- represent marks of fourth student
       marks[4] i.e. 100 – represent marks of fifth student

Thus using marks [0] through marks[4]  we can access the  marks of 5 students.
Note: Using marks [0] through marks [n-1] We can access the marks of n students in general.
In an array it not possible to have a group of items with different data types. Types. For example,

83
94.8
“Delhi”
‘3’
910
a[0]
a[1]
a[2]
a[3]
a[4]

Is invalid way of storing the elements in an array. This is because, it is a collection of int,  float, char
and string datatypes. Once we know the definition of an array. The next question is “How arrays
are classified?” The arrays can be classified based on how the data items are arranged for human
understanding. This is pictorially represented as shown below:



Pointer Declaration and Definition in c language

In C language, we know that all the variables should be declared before they are used. Pointer variable should also be declared before their use. The syntax to declare a pointer variable is shown below.

type *  identifier;

Type : type can be any datatype such as int, float , char etc. It may be derived or user defined data type also.
*       : The asterisk (*) in between type and identifier tells that the identifier is a pointer variable.
Identifier : Name given to the pointer variable. 

Example -1 : Consider the following declaration:
int * p;
The above declaration can be read as "p is pointer to integer variable" and this declaration informs the following points:


  • The variable p is a pointer variable. So, it should contain the address of variable during execution.
  • The type int refer to the type of the variable stored in pointer variable p i.e. the pointer variable p should contain address of an integer variable.

Example-2 : Consider the following declaration:
double *pd;
This declaration informs the compiler that pd is a pointer variable and can hold the address of a variable of type double.


Example-3 : In the declaration, the position of * is immaterial. For example, all the following declaration are same:
int *pa;
int * pa;
int*  pa;
Any of the above declaration informs that the variable pa is a pointer variable and it should contain address of integer variable.


Example-4 : Consider the multiple declaration as shown below:

int* pa,pb,pc;

Note : Here, we may wrongly assume that the variables pa, pb amd pc are pointer variables. This is because * is attached to int. This assumption is wrong. Only pa is a pointer variable, whereas the variables pb and pc are ordinary integer variables. For better readability, the above declaration can be written as shown below:

int *pa, pb, pc;

Now, we can easily say that pa is a pointer variable because of * operator, whereas pb and pc are integer variables and are not pointer variables. It is still better if the variable are declared in separated lines as shown below:
int *pa;
int pb;
int pc;



© Copyright 2013 Computer Programming | All Right Reserved