Posts

Types of C variables

As we saw earlier, an entity that may very during program execution is called a variable. Variable manes are names given to locations in memory. these locations can contain integer, real or character constant. In any language, the types of variables that it can support depend on the type of constants that it can handle.This is because a particular type of variable can hold only the same type of constant. For example, an integer variable can hold only an integer constant, a real variable can hold only a real constant and a character variable can hold only a character constant. Rules for Constructing Variables Names   (a) A variable name in any combination of 1 to 31 alphabets, digits or underscores. Some compiler allow variable manes, whole length could be up to 247 characters. Still, it would be safer to stick to the rule of 31 characters. Do not create unnecessarily long variable names as it adds to your typing effort.   (b) The first character in the variable name must...

Type of C constants

Image
C constants can be divided into two major categories :      (a)    Primary Constants      (b)    Secondary Constants these constant are further are categorized as shown in in figure. At this stage, we would restrict our discussion to only primary constants, namely, Integer, Real and Character constants. Let us see the details of each of these constants. For constructing these different types of constants, certain rules have been laid down. These rules are as under.   Rules for Constructing Integer Constants   (a) An integer constant must have at least one digit.   (b) It must not have a decimal point.   (c) It can be either positive or negative.   (d) If on sign precedes an integer constant, it is assumed to be positive.   (e) No commas or blanks are allowed within an integer constant.   (f) The allowable range for integer constant is -2147483648 to +2147483647. Ex :-  482   ...

Constants, Variables and Keywords

Image
the alphabets, numbers and special symbols when properly combined form constants, variables and keywords. Let us see what are 'constants' and 'variables' in C.   A constants is an entity that does not change, whereas, a variable is an entity that may change. In any program we typically do lots of calculations. the result of these calculations are stored in computer's memory. Like human memory, the computer memory also consists of millions of cells. the calculate values are stored in the memory cells. To make the retrieval and used of this values easy these memory cells (also called memory location) are given name. Since the value stored in each location may change the names given to these locations are called variable names. Consider the example shown in bellow.    Here 4 is stored in a memory location and a name X is given to it. then we have assigned a new value 7 to the same memory location X. This would overwrite the earlier value 4, since a memory locatio...

The C Character Set

Image
A character denotes any alphabet, digit or special symbol used to represent information. Figure 1 shows the valid alphabet, numbers and special symbols allowed in C

Getting Started With C

Image
Communicating with a computer involves speaking the language the computer understands, which immediately rules out English as the language of communication with computer. However, there is a close analogy between learning English Language and learning C Language, The classical method of learning English is to first learn the alphabets used in the language, then learn to combine these alphabets to from words, which in turn are combined to form sentences and sentences are combined to form paragraphs.         Learning C is similar and easier. Instead of straight-away learning how to write programs, we must first know what alphabets, numbers and special symbols are used in C, then how using them, constants, variables and keywords are constructed, and finally, how are these combined to form an instruction. A group of instructions would be combined later on to form a program. This is illustrated in the below...           ...

What is C

C is a programming language developed at AT & T's Bell Laboratories of USA in 1972.It was designed and written by a man named Dennis Ritchie. In the last seventies C began to replace the more familiar languages of that time like PL/I, ALGOL, etc. No one pushed C. It was not made the "official" Bell Labs language. 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 preferred 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. An opinion that is often heard today is C' has been already superceded by languages lik...

Octal Numbers

The octal number system uses the digits 0,1,2,3,4,5,6 and 7. The  base  or  radix  of    this system is eight. Each significant position in an octal number has a positional weight. The least significant position has of 8 0 there is 1; the higher significant positions are given weights in the ascending power of eight, there is, 8 [1] , 8 [2] , 8 [3] , etc. respectively. The octal equivalent of a decimal number can be obtain by dividing a given decimal number by 8 repeatedly, until a quotient of 0 is obtain. The procedure is exactly the same as the double-double method explained earlier.