Advertisement
Prithak

C Tutorial Text File

Feb 4th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. Basic Concepts
  2. What is C?
  3. -> C is a Mid-Level Programming Language developed at AT & T's Bel Laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchie. In the late seventies C began to replace the more familiar languages of that time like PL/I, ALGOL etc. There are many other languages present in this date! Some of them are C++, C#, Java etc. And some might say that in the presence of these languages C is useless. But it obviously isn't true!
  4. Some of the advantages of C are listed below:
  5. (a) C++, C# or Java make use of a principle called Object Oriented Programming (OOP) to organize the program. This organizing principle has lots of advantages to offer. But even while using this organizing principle you would still need a good hold over the language elements of C and the basic programming skills. So it makes more sense to first learn C and then migrate to C++, C# and Java. Though this two-step learning process may take more time, but at the end of it you will definately find it worth the trouble.
  6. (b) Major parts of popular operating systems like Windows, UNIX, Linux and Android are written in C. This is because even today when it comes to performance(speed of execution) nothing beats C. Moreover, if one is to extend operating system to work with new devices one needs to write device driver programs. These programs are exclusively written in C.
  7. These are the major advantages of C
  8. clearscreen
  9. Constants and Variables
  10. ->The alphabets, digits and special symbols when perfectly combined form constants, variables and keywords. Let us now understand the meaning of each of them.
  11. A constant is an entity that doesn't change.
  12. A variable is an entity that may change.
  13. In any C Program we typically do many calculations. The results of these calculations are stored in in computer's memory. Like human memory the computer's memory also consists of millions of cells that store data.
  14. The calculated values are stored in memory cells. To make the retrieval and usage of these values easy, these memory cells are given names.
  15. Since the values stored in each location may change, the names given to these locations are called variable names.
  16. If we declare x = 3 (Meaning X is equal to 3)
  17. And we declare y = 5 (Meaning Y is equal to 5)
  18. And again we declare x = 6
  19. Then, the value of x will be changed to 6!
  20. Since the locations whose name is x can be changes at different times, X is known as a variable. As against this, 3 or 6do not change, hence they are known as constants.
  21. clearscreen
  22. Types of C Constants
  23. C contains two different types of constants. And they are:
  24. (a) Primary Constants
  25. (b) Secondary Constants
  26. Right now, we are only going to read Primary Constants, Secondary Constants will come later on in this tutorial.
  27. Primary Constants are also divided into 3 parts. They are:
  28. (a) Integer Constant
  29. (b) Real Constant
  30. (c) Character Constant
  31. There are some rules for constructing constants. The rules type-by-type are as follows:
  32. clearscreen
  33. Rules for Constructing Integer Constants
  34. (a) An integer Constant must have at least one digit.
  35. (b) It must not have a decimal point.
  36. (c) It can be either positive or negative.
  37. (d) If no sign precedes an integer constant, it is assumed to be positive.
  38. (e) No commas or blanks are allowed within an integer constant.
  39. (f) The allowable range for integer constants is -2147483648 to +2147483648
  40. If we speak truly, the range depends upon the compiler you are using! For example, gcc and Visual Studio ranges from -2147483648 to +2147483648. While, Turbo C++ the range is -32768 to +32768.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement