[tutorial] Basics Of C Programming - Part 1

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #11) by rsguidez on Jul 14 2008, 09:20 AM. (Line Breaks Removed)
this realy helped me thank you
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Free Web Hosting > Computers & Tech > How-To's and Tutorials > Programming > C and C++

[tutorial] Basics Of C Programming - Part 1

dhanesh
Well, I was going through a few posts on C / C++ on asta .. and found a very less C related subjects. I went through the entire tutorial of mastercomputers >>HERE<< .. It was a nice tutorial for guys who have a little knowledge of programming basics and want to go into hardcore programming. Since there was no Basic overview of what C was, i thought of writing one smile.gif. I wil make shure that what i write will be 100% accurate, but its human to error so please correct me if i am wrong. Lets start off ...

Introduction to C

Topics Covered :
  • History of C
  • Characteristics / Features
  • Structure of a C Program
  • Desirable Program Characteristics
  • C Character Set
  • Identifiers & Keyword
  • Constants
  • Expression
  • Statements
  • Symbolic Constants

History of C

  • This language was developed by Dennis Ritchie in 1970 at t he Bell Lab.
  • It was official released only in 1978.
  • 1980s it evolved as a most effective language because of its desirable features.
  • It was instantly adapted even for developing commercial applications
  • Many Software products which were written in other languages we rewritten in C for its efficiency and portability.
  • With the advent of C many C compilers and interpreters were written and released into the market
  • They differed from the original C language this lead to the lack of portability that the language promised to provide
  • AT this point ANSI developed certain standardized norms for the C language and today all C compilers adhere to this ANSI Standard.
Characteristics / Features
  • Ability to write very concise source codes in spite of having a large number of operators.
  • It has a small instruction set
  • It has library functions that enhance the basic instruction.
  • The features and capabilities can be easily extended b the users as it encourages users to write additional library functions
  • C Compliers are compact and generate smaller and highly efficient object code compared to other high level languages.
  • C Programs are highly portable as its library set avoids all to computer dependent features.
  • C Compliers are compact and generate smaller and highly efficient object code compared to other high level languages.
  • C Programs are highly portable as its library set avoids all to computer dependent features.
Structure of a C Program

CODE
/* Simple Program to Add 2 Values*/            /* Title*/[/color]
[color="#996633"]# Include<stdio.h>                        /*Library File Access*/
main()                                          /* Function Heading*/
{                                                  /* Start of the Function*/
    int n1,n2,sum;                          /* Variable Declaration*/
    printf(“Enter First Value : “);        /* Output Statement */
   scanf(“%d “,&n1);                       /* Input Statement */
   printf(“Enter Second Value : “);    /* Output Statement */
   scanf(“%d “,&n2);                       /* Input Statement */
   sum=n1+n2;                              /* Assignment Statement*/
   printf(“Sum is : %d “,sum);          /* Output Statement */
}                                                  /* End of function Main*/



Desirable Program Characteristics
  • Integrity
  • Clarity
  • Simplicity
  • Efficiency
  • Modularity
  • Generality
C Character Set

  • Uppercase A - Z
  • Lowercase a - z
  • Digits 0 – 9
  • Special characters
These are used as building blocks to form basic program elements


Identifiers & Keyword

Names given to basic program elements such as variables, Functions etc. Certain norms they have to follow:
  • Name can be of alphanumeric type
  • But should start with a alphabet
  • It is case sensitive
  • Keywords are reserved words that have a predefined function in C
  • Keywords can be used only for the purpose they are intended for
  • Keywords Cannot be used as program defined identifiers
Constants

They contain a specific value.
Four types :

Integer & Floating Point Constants

They are normally reffered to as numeric constants
Follow certain norms:
  • Commas and blanks cannot be included within the constant
  • Can be preceded with a – sign if required
  • Value should be within the specified range .
Integer Constants

These are nothing but integer valued numbers.
Can be written in 3 number systems :
  • Decimal Integer Constant ( Base 10)
Contains digits between the set 0 to 9
If consists of more than one digit should start with a value other than zero.
  • Octal Integer Constant ( Base 8)
Contains digits between 0 to 7
First digit must be a zero
  • Hexa Integer Constant (Base 16)
Begins with a either 0x or 0X followed by digits
Set could contain 0 to 9 and a – f (Lower or Uppercase)

Floating Point Constants

  • This is a base 10 number having a decimal value or a exponent.
  • In case of representation of a exponent is similar to the scientific notation except that 10 is replaced by E or e
Eg : 10.8X 10 -3 : 10.8E-3 or 10.8e-3

Character Constants

  • Single character enclosed within Single apostrophes
  • All character constants have integer values that determine them in the character set .
  • Character set standardized by the ASCII here each character is numerically encoded with its own unoaque 7 bit coding
Combination of special characters that are used for special purpose .
Always started off with a \ .
Eg \n, \t etc.

String Constant

  • Consecutive sequence of characters within double quotations.
  • Uses \0 ( Null) string terminator at the end of the string.
Expression

  • Represents a single data item which could be a number or character .
  • It could be single entity as a variable function or constant or a combination of entities connected by a operator.
Eg. C=a+b;


Statement

This Causes the computer to perform a action
Types:
  • Expression Statement
  • Compound Statement
  • Control Statements.


Symbolic Constant

  • Name that substitutes with a sequence of characters.
  • These sequence of characters could represent a numeric , character or a string constant.
  • They have to be defined at the beginning of the program
  • Done by using the keyword : # define pi 3.141
Well i hope this helped a few new commers to the programming field, I am a little bored and tired now .. but will finish the next topic of Operators & Expressions in C , in the next tutorial. Suggestions and Critisizm are welcome smile.gif ..

Regards
Dhanesh.

 

 

 


Reply

OpaQue
Awesome presentation! I m impressed!

Reply

Chesso
Yep looks fairly good and structured to me. I think that code tag posted C code needs a bit of fixing though somehow because things are a little squished.

Perhaps a few more basic code examples would be nice for newcomers to try aswell?

Reply

dhanesh
Thankx Opaque & Chesso .. Yeah the code is kinda squished .. will try to fix that in my next posts .. as for a few basic examples .. I guess the post mastercomputers made would suffice. But if i am in the time zone again, i'd love to post a few basic examples of code in C. smile.gif

Regards
Dhanesh.


Reply

Omkar™

Great! I'm an 'A+' grader in C Programming, and that was quite a good head start!

Awaiting Part II (Or maybe can I write it? wink.gif )

Reply

dhanesh
QUOTE(Omkar™ @ Jul 27 2006, 06:44 PM) *

Great! I'm an 'A+' grader in C Programming, and that was quite a good head start!

Awaiting Part II (Or maybe can I write it? wink.gif )

Dude .. go on ! no permission needed .. if you can get to the level of a newbie .. then go ahead. It sucks when it conmes to being a n00b at things, and only 10% "TRY" to help you .. 5% "WANT" to help you.

I actualy am in the middle of writing the second part right now, so if u want to add up .. or start a new one .. please do so .. dont ask wink.gif ..

Regards
Dhanesh.

 

 

 


Reply

lonebyrd
I'm sorry, but most of that looked greek to me. I know a little scripting: alot of HTML, some php, but most of that, I did not get. Maybe I just did not get enough sleep last night. I was up early this morning. But I know it must be hard trying to teach an absolute beginner to something.

Reply

Quatrux
Well done, this is quite informative tutorial, especially for beginners and maybe average ones to get over it again, even though I never got into c, but I used to play around with it, but mostly on Amiga OS and Linux, somehow I moved to PHP+MySQL and didn't do anything special with c. In addition, c is so similar to PHP, the syntax and most of us I guess knows why biggrin.gif

Reply

Chesso
If you are ever up for dHanesh a beginners guide to C++/Win32 programming would be absoolutely great, I know how difficult it is to get started with programming the Win32 API for a basic GUI.

It'd be a fair bit larger of a tutorial heh heh but well worth it if done well. You could always get feedback from members here on it too and make it even better smile.gif

Reply

iGuest
Your tutorial in 'see'language is very nice.I want to learn 'see' language by your toturial. good afternoon & have a nice day.

-dilip rajpurohit

Reply

Latest Entries

rsguidez
this realy helped me thank you biggrin.gif

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Recent Queries:-
  1. color tutorial in c programming - 159.74 hr back. (1)
  2. basics of c programing - 162.42 hr back. (1)
  3. the basics of the c language - 173.56 hr back. (1)
  4. c language from the basics - 177.51 hr back. (1)
  5. basics c - 178.93 hr back. (1)
  6. amiga basics - 180.37 hr back. (1)
  7. code for average of ten numbers in c-programming - 181.54 hr back. (1)
  8. average of ten numbers in c-programming - 186.29 hr back. (1)
  9. basics of c - language lessons - 186.64 hr back. (1)
  10. basics of c - 157.03 hr back. (10)
  11. free c programming basic vidoe tutorial - 201.19 hr back. (1)
  12. basics of c language - 159.08 hr back. (9)
  13. how to write a library in c tutorial - 203.64 hr back. (1)
  14. c language basics - 155.32 hr back. (17)
Similar Topics

Keywords : , tutorial, basics, c, programming, part, 1

  1. [tutorial] Basics Of C Programming - Part 2
    (20)


      Looking for , tutorial, basics, c, programming, part, 1

Searching Video's for , tutorial, basics, c, programming, part, 1
advertisement




[tutorial] Basics Of C Programming - Part 1



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE