[tutorial] Basics Of C Programming - Part 2

Pages: 1, 2, 3
free web hosting

Read Latest Entries..: (Post #20) by Chesso on Aug 11 2007, 11:15 PM. (Line Breaks Removed)
C was a non object oriented programming language, C++ is just a well, more updated version of C that includes more modern standards including OOP.As for the last one you mentioned, I think you mean Visual C++ and variants, which are Microsoft products (Microsoft Visual C++).
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 2

dhanesh
Ok, well here is the Second part of the tutorial i promised.

Operators & Expressions in C

Introduction

  • In c the variable, arrays or function references are combined with operators to form expressions.
Eg. C=A+B
  • The data items that the operators act upon are called operands.
  • Some operators require two operands will others require just a single operand to act upon.
Types Of Operators :

  • Arithmetic Operators
  • Unary Operators
  • Relational and Logical Operators
  • Assignment Operators
  • Conditional Operators
Arithmetic Operators

  • + : Addition
  • : subtraction
  • * : Multiplication
  • / : Division
  • % : Modulus
  • The operands must represent numeric values
Eg : Integer, Floating, or characters – C character set
  • % : Both operands must be integer and second one nonzero.
  • / : Second operand must be a Nonzero.
  • Both operands are integers then referred to as integer division
  • Operation is carried by two floating values then Floating point division.
  • If one integer and the other float then the result will be floating quotient.
Type Cast : Converts the value of an expression to a required data type if needed.
Syntax ( Data type) Expression
Eg. ((int)cool.gif%4

Unary Operator:

  • They act upon a single operand to produce a new value.
Types :
  • Increment Operator
++ : Increments the value in the operand by 1
Eg: ++a, a++
  • Decrement Operator
--: Decrements the value in the operand by one
Eg. : --a, a--.
  • sizeof : returns the size of the operand in terms of bytes. And is always preceded by its operand.
Eg. Printf( “THE SIZE OF VARIBALE A IS : %d”, sizeof a);


Relational and Logical Operator:

Relational Operators :
  • <= : Less than or equal to
  • >= : Greater than or equal to
  • > : Greater than
  • < : Less than
  • == : Equal to
  • != : Not Equal to
Logical Operators :
  • && - and : Both the conditions should hold true
  • || - or : Either one of the condition should hold true for the action to be performed.
Assignment Operators :
  • They are used to form an assignment expression
  • It would assign a value of an expression to a identifier.
Types :
  • =
  • +=
  • -=
  • *=
  • /=
  • %=
Conditional Operator :
  • Used for carrying out conditional operations – ( ? : )
  • Syntax : Expression 1 ? Expression 2 : Expression 3
Eg. i=10
ans= (i<=10) ? 0 : 1

Yeap, well that wraps up the Conditional Operators topic. As suggested, i would post some examples of code later on, but till then you could go through these basic guidelines and perfect them. Hope this helped smile.gif

Regards
Dhanesh.

 

 

 


Reply

Omkar™

Alright, that did make a great Part II, and you didn't screw up any code this time either! Good work, but you missed out some things (Of course you can't teach C Prog. in 2 parts biggrin.gif ) so I'd write Part III, if I get time, that is! No, really - I'm working hard on my website right now, and filling up my forums too!

Honestly, you should be adding some examples and some assignments too, as a good tutor!!! cool.gif

Reply

dhanesh
LOL omkar .. true but hard to believe, I'll kill someone if they dont understand what i teach .. lol tongue.gif . I am a really impatient tutor. Guess i have to be working on my teaching skills from now. hehe ..

As for Part 3 .. Its all yours, really .. I havent started yet .. so whenever you get time .. go on and complete whatever i have missed out. Its not easy to complete C in 2 parts true, so i hope you will add up a few pointers for us then wink.gif ..

Thankx for your comments.
Regards
Dhanesh.

Reply

cyborgxxi
Hey Dhanesh

Long time no see, digital brother. <LOL
Wow I am just amazed at how much you guys are literate in computer programming languages. For me, it's HTML and I only know the basics. Well, it's kinda sad but I guess it can hold out for a little time being while I go try to learn PHP.

Can someone answer my question:

How can you benefit from being literate in C programming and C++?? What about C++ Visuals? Is that another programming language too?

By the way, wonderful job there, Dhanesh. Kudos for you.

Reply

dhanesh
QUOTE(cyborgxxi @ Jul 29 2006, 05:36 PM) *
Hey Dhanesh
Long time no see, digital brother. <LOL


Aha .. the Hobbes of asta tongue.gif .. long time indeed, where have u been bro and how've you been ?. Seems like you were bz with ur website. Best of luck for that smile.gif share it with us sometime ..
QUOTE(cyborgxxi @ Jul 29 2006, 05:36 PM) *

Can someone answer my question:

How can you benefit from being literate in C programming and C++?? What about C++ Visuals? Is that another programming language too?


I think the best people to answer this would be people who are INTO programming. But lets see, by learning C / C++ which are the foundation of any programming languages today, you would be able to design/program applications flexibly. Visual C++ is a form of basic command C/C++, just with a pretty GUI and with the title of M$, i have seen people who prefer the basic C/C++ more to the Visual C++. One major difference would be the syntax, Different programming languages have different syntax, but its easy to cope up when you are fluent with 1 basic language.

I love to work on Visual Basic, and to be honest, i have to be changing that, cause tho VB might seem easy with GUI and stuff, its not so flexible as command C/C++ ..Hope you get the basic point .. Anyone else who can elaborate on this is welcome smile.gif ..

Hope you see more of you around Hobbes ... lol biggrin.gif
Regards
Dhanesh.

 

 

 


Reply

gem.ini
These are old knowledge... I miss them sooo!!

Reply

yordan
QUOTE
Honestly, you should be adding some examples

I agree.
Mainle, I see what ++i is (it changes i to i+1).
I would like to know what += means. if a=-1, += applied to a makes it change to -2 or to 0 ?

Reply

techocian
Hey Dhanesh, hobbes laugh.gif , long time no see.

I've been studying Visual Basic for the past few weeks now as a course in school. It's getting a little more complicated now that i've moved up to ifs and elses. Some of the operators i see used in C (as you have portrayed) is really similar to that of Visual Basic, one difference i can point out though, is how to make equations equal, that is using the double equal sign (==). It reminds me of back when i was studying a little php. They say that Visual Basic is a good base before moving on to other languages such as C or C pluses, it doesn't seem so at first glance, and if you know me, I'm not a very good reading learner wink.gif .

Going out of the topic for a moment. The book we're using in our Visual Basic course describes something about pseudocode. Where you actually incorporate understandable English language as code. A friend told me it is just a form of "laying out" your code into more understandable parts. But I'm wondering if pseudocode actually works as a language itself?

Reply

SP Rao
It was a good tutorial indeed. Though I did find some omissions.
1)First you didn't differntiate between a++ and ++a. May be you have a plan of explaining it later.
2) You have left out bitwise operators completely. (Operators like XOR-^ , OR- | , AND - & , NOT - ~ ). In fact along with the assignment operators you've mentioned, the following also hold good.
|=,
&=,
^=.
3)Also, there are bitshift operators. Bitwise left shift (<<) and bitwise right shift(>>) operators whih help in doing bitshifting operations.

Once again I repeat I'm not sure if you have plans of covering these in your next part. But if you didn't have such plans, you can include these in your next part of the tutorial biggrin.gif

Reply

Chesso
It looks like a great piece of information to me, Iv'e done DLL's and things in C++ and still didn't know some of that tongue.gif.

Reply

Latest Entries

Chesso
C was a non object oriented programming language, C++ is just a well, more updated version of C that includes more modern standards including OOP.

As for the last one you mentioned, I think you mean Visual C++ and variants, which are Microsoft products (Microsoft Visual C++).

Reply

dani2810
Hey,

Long time no see, digital brother. <LOL
Wow I am just amazed at how much you guys are literate in computer programming languages. For me, it's HTML and I only know the basics. Well, it's kinda sad but I guess it can hold out for a little time being while I go try to learn PHP.

Can someone answer my question:

How can you benefit from being literate in C programming and C++?? What about C++ Visuals? Is that another programming language too?

Reply

vidit
Thankx for the second part man, glad to learn it. rolleyes.gif
I think i'm gonna learn a lot here.smile.gif

Reply

Chesso
C and C++ aren't too different, C++ is more an upgrade to add Object Orientation to the mix.

Reply

matthewk
Wow, I hope these guides keep coming! There are a lot of differences for me for C compared to c++ and java. I like the syntax better in c++ and java, so the more guides I can read like this, the better off I am! Thanks a lot for your hard work smile.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, 3
Recent Queries:-
  1. programming basics:c - 68.20 hr back. (1)
Similar Topics

Keywords : basics programming

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



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

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




[tutorial] Basics Of C Programming - Part 2



 

 

 

 

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