Wednesday, November 24, 2010

First C Program...

Well guys!.......Greetings..!

I am sorry as i could not write a new post but today we gonna be read Character Variables. The first thing for character variable is it should be a character and write like 'a', if you want declare a character variable then you need to write it like-

void main()

{

char b;

b='C'

------

------

}

Maximum character length should be one character.

Now i know you are thinking how to construct variable name.....OK....lets read below:

1-variable name is any combination of alphabets and numbers.

2-first character should be an alphabet or an underscore.

3-No comma or blanks are allowed to construction of a variable.

Ex.-

sum_numbers

so_int

a_sex

b_a_46

and now you have learnt How to construct the variables so please read C keywords-

you are thinking what is C keywords, keywords are the certain words whose meaning already known by compiler, key words can't be used as variable name .....hehe note it, there are 32 key words 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

SO after learning all the basic things now we will make a first C program.......(if there is any query regarding above explained details kindly mail me)

Input for your first C program-

And Output would be-

1- #include is a header file which means compiler already know about header files.

2- void main () is collective name given to a set of statements.

3- A pair of braces {} shows statement by void main().

4- We used printf("....") for print, that means output screen print.

5- ";" is to be used on every statment to finish it...you will know ablut it in next programs.

Another Program for calculate simple interest—

Output-

Sunday, November 21, 2010

Character set for C

Well, I know you are very eager to learn more as you already know the process in last post for making a program, now theoretically i will explain how a program made-



Source Code:- The code we type/write in C language.

Compile:- This is a term to change source code to machinery language and follow the instruction which we asked to computer for. it can be called interpreter.

Object Code:- After compiling the program, the output called object code.

Now ! come to the topic for character set of C language is-

1- Alphabet- A to Z, a to z.
2- Digits- 0 to 9.
3- Special symbols- ~ ' ! @ # % ^ & * () _ - + = | \ {} [] : ; " ' <> , . ? /



Constants- kindly go through with below mentioned fig.





1st- Integer- I think you are well aware about Integer, here in C are few rules for integer value-

- It should be at least one digit, no decimal point, no comma, no blank space.
- unsigned is assumed as positive integer.
- The range for 16 bit compiler for a integer is -32768 to 32767.

for example:-
main ()
{
int a= 12; /* int a is an unsigned integer*/
-------
--------
}

2nd- Real Constants- It also called floats, rules are mentioned below-

- must have a decimal point in a digit and no commas or blank-space allowed.



Example:-

main()
{
float b=1.2e-5;
float a=1.2;
--------------
-------------
------------
}

Now remaining chapter will explain in next post so till now keep reading........!

Friday, November 19, 2010

What are the steps for C language?

Here is a figure which will show you how to learn C, I am going stepwise as i think you can learn better if i will do that.




Hence the program is combination of above-said parts, and in next post i will explain these parts.

ABOUT C:

Before we know how to write a typical/simple C program let us know what is C exactly, C is a programing language developed at AT&T's Bell Laboratories of USA in 1972. it was designed by Dennis Ritchie. C language is very user friendly language that is why it is existing for last 3 decades because every new day a new technology is taking birth. The base of all languages like C++, Java etc. is C language and many application in MS Windows OS are developed in C language, so C language is very user friendly.