Enter your email address:

Delivered by FeedBurner

Tuesday, December 28, 2010

First C Sample Program

Let us now write down our first C program.

/*calculation of simple interest*/
/*my first c program*/

#include <stdio.h>
int main()
{
    int p,n;          /* declaration*/
   float r,si;       /* declaration*/

   p=1000;
   n=3;
   r=8.5;
    /*formula for simple interest*/
   si=p*n*r/100;     /* usage*/

   printf("%f",si);
   return 0;
}

C does not contains any instructions to display output on the screen. All the output to screen is achived using readymade library functions. One such functions is “printf()”. we have used it display on the screen the values contained in “si”.

Tuesday, December 14, 2010

C keywords

Keywords are the words whose meaning has already been explained to C compiler. The keywords Cannot be used as variable names because if we do so, we are trying to assign a new meaning to the keywords, which is not allowed by the computer. Some C compilers allow you to construct variable names that exactly resemble the keywords. 

 

The Keywords are also called ‘Reserved Words’. There are only 32 Keywords available in C.

 

List Of 32 keywords available in C

auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while

Sunday, December 12, 2010

Types Of Constant In C

C Constants can be divided into two major categories:

1: Primary Constants

2: Secondary Constants

Primary Constants

Integer Constant

Real Constant

Character Constant

Secondary Constants

Array

Pointer

Structure

Union

Enum. Etc.

What is Constant in C Language

 

A Constant is an entity that doesn’t change, whereas, a variable is an entity that may change.

 

In any program we typically do lots of calculation. The results of these calculation are stored in computer’s memory also consists of millions of cells. The calculated values are stored in memory cells. The values stored in each location may change the names given to these locations are called variables names.

 

Example:

Now “3” is stored in an memory location and a name x is given to it.

Then we have assigned a new value 5 to the same memory location x.

This would overwrite the earlier value 3, since a memory location can hold only value at a time.since the location whose name is x can hold different times x is known as a variable. As against this, 3 or 5 do not change, hence are known as constants.

C Character Set

A character denotes any alphabet, digit or special symbol used to represent information.

 

Alphabets: A, B, ………, Y, Z

Digits: 0,1,2,3,4,5,6,7,8,9

Special Symbols: ~ ` ! @ # $ % ^ & * ( ) _ – + = | \ { } [ ] : ; “ ‘ < > , . ? /

 

These are valid alphabets, numbers and special symbols allowed in c.

Saturday, December 11, 2010

What is C Language

C is a Programming Language developed at Bell’s Laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchies. In the Late Seventies C began to replace the more familiar language of that time like PL/I, ALGOL, etc. No one pushed C.Thus, without any advertisement, C’s reputation spread and its pool of users grew . Ritchie Seems to Have Been Rather surprised that so many Programmers C to older Languages like FORTRAN or PL/I, or the newer ones like Pascal and Apl. But that’s what happened.

 

Possibly why C seems so popular is because it is reliable, simple and easy to use. Moreover, in an industry where newer languages, tools and technologies emerge and vanish day in and day out, a language that has survived for more than three decades has to be really good.

 

    • I believe that nobody can learn C++ or Java directly. This is because while learning these languages you have things like classes, objects, inheritance, polymorphism, templates, exception handling, references, etc. do deal with apart from knowing the actual languages elements.
    • Hence one should first learn all the language elements very thoroughly using c language before migrating to C++, C# or Java.
    • Mobile devices like cellular phones and palmtops have become rage of today. Also, common consumer devices like microwave ovens, washing machines and digital cameras are getting smarter by the day. This smartness comes from a microprocessor, na operating system and a program embedded in these devices.
    • You must have seen several professional 3D computer games where the user navigates some objects, like say a spaceship and fire bullets at the invaders.
Related Posts Plugin for WordPress, Blogger...