C Language

blog

C is a middle level functional programming language. Where functional means all work done in c in form of function .Middle level means c stands in between these two categories. Because it have good programming efficiency as compare to low level language and good machine efficiency as compare to high level language.

C Language”

C is a middle level functional programming language. Where functional means all work done in c in form of function .Middle level means c stands in between these two categories. Because it have good programming efficiency as compare to low level language and good machine efficiency as compare to high level language.

“Development of C”

It developed by Dennis Richie in 1972 in USA at AT&T Bell Laboratories. In C a character denotes any alphabet, digit or special symbol used to represent information. Ex. a to z, 0 to 9 and ―~ ! @ # % <>.

“Constant, variable and keyword” When alphabets, numbers and special symbols properly combined to form constant, variable and keywords.

“Constants”

A Constant is a quantity that does not change. This quantity can be stored at a location in the memory of a computer.

“Variables”

A quantity which may very during program execution is called a variable.

“Variable name”

A name given to locations in the memory of computer where different constants are stored. These locations can contain integer, real or character constants.

“Keywords”

Keywords are the words whose meaning has already been explained to the C Compiler .Keywords cannot be used as variable names keywords also called Reserved words there are 32 keywords available in C. Ex.auto, double, if, continue, do, goto , signed, while, void, uniox, switch etc.

“Types of C Constant”

We can divide C Constant into two categories.

I. Primary Constants

II. Secondary Constants

“Primary Constants”

” Integer”

” Real or Float”

“Character “Integer”

” Integer”

Have no decimal and fractional values It have at last one digit. No commas OR blanks are allowed in integer constant. It could be either positive OR Negative It have 2 Bytes in memory Range for integer constant is-32768 to 32767 declaration of integer constant is ―Int‖ and Conversion specified of integer is %d OR %I

“Real Constants”

Real constant are also called float constant real constant could be written in two forms. Fractional Form Exponential Form A real Constant must have at least one digit. It must have a decimal point. It could be either positive OR Negative default sign is positive. No commas OR Blanks are allowed within a real constant. They have 4 Bytes in memory. Range of real constants -3.4e38 to 3.4e38 declaration of real constant is float and conversion specifier of real constant is %f.

“Character Constant”

A Character constant is either a single alphabet,digit,special symbol enclosed within single inverted commas. Declaration of character constant is Character and Conversion specifier of character constant is %c Range of character Constant is -128 to 127. Ex. a = `A‘;

“C Variables”

A quantity which may vary during program execution is called variable.

“Rules for Constructing variable names”

1. A Variable Name is any Combination of 1 to 8 Alphabets, digits and underscore.

2. First character in the variable must be an alphabets.

3. No Commas and Blanks are allows in the variable Name.

4. No special symbols other them underscore can be used.

“C Instructions”

DEF.:- different types of constant ,variables and keywords combined to each from instructions There are 4type of instruction in c language

1. type declaration instruction

2. input/out put instruction

3. Arithmetic instruction

4. Control instruction

“Purpose of instructions

1. type declaration instruction are used to declare the type of variables

2. Input/ output instruction are used to perform the function of supplying input data to a program and obtaining the output results

3. Arithmetic instruction to perform arithmetic operation between constants and variables

4. Control instruction are used to control the sequence of execution of various statements Type declaration instructions are written at the beginning of the program In arithmetic instruction consists variable name on the left hand side and constants placed on the right hand side of ―=‖.

“Operands”

The variables and constants together are called operands which are operations in an arithmetic statement are performed is called the hierarchy of operations . Priority Operators 1 st *,/,% 2 nd +,- 3 rd = Or “ Bodmas “ is the hierarchy of operations .(Brackets ,open ,divvied , multiplictication , addition , subtraction comparison with English language. Alphabets -> word-> sentence -> paragraph “C language “ Alphabets —> constants Digits —> variables —> instruction—> program Symbols —> keywords

“Conversion specifies

Conversion specifies indicates the computer a number is in the from of character , float, integer. Some specifies given below %d for integer % f for float % s for string % c for character % p for hexadecimal number

“/* Comments .*/”

we may type more than one argument in the between these two sets of characters and compiler will ignore them

“# Include < stdio .h >

Where # include is called directive and the standard input output header file .It is a good habit to include this directive at the beginning of any C program ― ; (Semicolon at the end of a statement semicolon indicates the compiler that a statement is finished .All the programs are written in lower case in C program “\n” To go to next line “\T” To give tab of 5 spaces

“Oh shell”

Temporary exit from C or to go to the dos prompt. Again go to the program give exit

“ Clrscr();”

To clear the screen

“Declaration of variables”

When we use variables in a program then first of all beginning of a C program Variable must be in float and character type .

“Assignment”

After declaration of variables we assign values for these variables multiple assignment is possible in c we can assign the given value for more than one variables Ex x=y 2=24;

“operators”

we have three type of operator in C language

1. Arithmetic operators

2. Relational operators

3. Logical operators

“ Arithmetic operators”

-,+,*,/,%,- -,+ +,=

“Relational operators”

> > >= <= = = != Not equal to

“Logical operators”

$$ and :: or ! Not ―=‖ is used in assignment a value ―= =‖ is used in loops for conditions

“Long integer”

:- range –2147483648 to +2147483647 Declaration :- long int. Variable name Conversion spacifier = % ld

“Unsigned integer”

range :- +65535 it does not except –xe value declaration :- unsigned Int. variable name Conversion specifies = % u

“ Float or real”

Float :- Range –3.4e38 to +3.4e38 Declaration :- float variable name Conversion specifier :- %f “Double float” range :- -1.7e308 to +1.7e308 Declaration :- double variable name Spacifier :- %lf

“Character”

character :- range –128 to 127 declaration :- character variable name Conversion Specifies :- %c

“unsigned character”

range:- 0 to +225 Declaration :- unsigned character variable name conversion Spacifier :- %C

When we save our program the computer or file with different Extension

1. Program file .C

2. Save program .bak

3. Compile program .obj

4. Run program .exe These file make in out directory “#Include < conio.h>” Consol Input out put header file. “#Include < math.h>” Mathematical function header file “Lib directory” Lib directory have library functions Included directory have header, file “Purpose” \N new line \B back space \F from file \T tab

“ Main( )”

It is the first function ( that) during the program execution every program must have one main function the function main always followed by ( ) parentheses which may be empty. Syntax: – main () { Statement; }

“Print f”

It is formatted out put function this function allowed us to obtained the output in a fixed format. Syntax: – print f (― conversion specified ―,Variable name)

“Scanf”

Scanf is a standard C library function which reads in key board input of the specified data and the$ operator is used to indicates the addresses of data item in the computer memory Syntax: – Scanf (― conversion specifies‖, & variable name)

“ If condition”

It condition is always enclosed with a pair of parentheses of the condition is true the statement is executed .If condition is false the statement are not executed If statement is not terminated at the end of the Parenthesis Syntax: – If (condition) { Statement1; Statement2; } All the statements written in if condition always were terminated

“ Multiple statements with in if “

If more than one statements to be executed if condition is statements are enclose with a pair of braces Syntax: – if (condition) { Statement; Statement; Statement } If a pair of braces is not used then C compiler assumes that (the) to executed only first statement of the program only

“The if – else statement”

If else statement execute one group of statement if condition is true if condition is false then execute the group of statement which are played after the Else statement Syntax: – If (condition) { Statement; Statement; Statement; Statement; } Else { Statements; Statement; } The group of statement after if and below Else is called an ―if block‖ and the statement after the else from the ―Else block‖

“Nested if –Else”

(f) It is perfectly alright if we write on entire if else construct within either the body of the if statement or the body of an else statement this is called nesting if else statement Syntax: – if (condition) { If (condition) { Do this } Else { Do this and this } Else { Do this; }

“Use of logical operators”

C allows only three logical operators 1. && ―And‖ 2. || ―Or ― 3.! ―Not‖ We do not use single symbols have their own meanings && And || operator allow two or more conditions to be combined in an if statement .And the third operator not operator makes a true part or expression false and a false expression in true . Hierarchy logical operators. * /% + – < > < =>= = =! = && || And = assignment ―Conditional operators‖ And | sometimes called ternary operators since they take three arguments Syntax: – If (condition)? Expression! : Expression If condition is true then expression will be executed other wise expression two will executed “Limitations” After the condition operators only one C statements can occur

“ While loop”

Syntax: – While (condition) { Do this and this Increment or decrement } The statement within the while loop would be executed till the condition remains true when. The condition being tested may use relational or logical operators Ex. While (! < = 10 &&j <=15) OR while (J>10&&(b<15 \\ c<20) It is not necessary that trop counter must only be an and it can even be a float

(“Increment and decrement operator “)

In C program we give increment and decrement in fallowing ways I+ + or + + I For one decrement in i If we want to increase no more than one them one then we give i+2 or I+ 2=i Difference between ++ i and i ++++ i:- First of all increment of i takes place and than the comparison with condition is performed i++:- First of all comparison of i with condition takes place and then increment of i takes place

“ Do while loop”

syntax :- main ( ) { Do { this and this } while ( condition); } ― Difference between while and Do-while loop‖ In while loop condition is tested before the execution of statements but in do-while loop the statements execute before the condition tested.

“Continue statement”

Continue is a keyword continue passes the control automatically to the beginning of the loop. A continue is usually associated with an of condition. Syntax:-Continue;

“Break statement”

Break is a keyword when Break encountered inside a c. program control automatically passes to the first statement after the loop. Break statement associated with an of condition. Syntax:-Break; Break statement passes the control to the firstly statement after the loop. But exit statement termination whole program. ―Difference Between Break and Exit‖

“Operators”

―Arithmetic operators‖ Expression:-Expression built up from literals, variable and operators. Operators:-The operators define how the variable and literals in the Expression will be manipulated.

“Arithmetic operators”

+,-,*,/,% are the Arithmetic operators which are used for Addition, subtraction, multiplication division and modulus modulus division operator(%) gives the remainder of the Integer division.

“ Relational operators”

Relational operators are used to compare values forming relational Expressions.  areater than  areater than equal to  less than  less than equal to  is equal to  not equal to

“Precedence of Relational logical operators”

>>=<<= ==!= && ‗‘ ‗‘

“ ASSIGNMENT operators”

The simple equal sign(=) is the Assignment operators. ―+=‖ It includes Both inereament and assignment so it could combined operators. Ex. *** x-=y; or x=x-y; x*=y; x=x*y; x/=y; x=x/y; x%=y; x=x%y;

“Size of operators”

The size of operators is used to return the size in bytes of its operand. Syntax:-Size of (n); Where n is a variable.

“Bitwise operators”

& AND | OR ^ XOR ~ ones complement. >> Right shift << Left shift. Precedence of Bitwise operators ~ << >> & ^ ! All of the Bitwise operators are evaluated from left to right. ―Precedence of c operators‖ ( ) [ ] – > Left to right /~ ++ — &* size of right to left */% left to right = – ― << >> ― < < =>= ― ==!= ― & ― ^ ― | ― && ― ?: ― = + = – =/= right to left , ―

“GETCHE”

getche means get character echa.The getche function assins the letter to the variable as soon as. It is enter without watching for the enter key to be press. Ex. Main( ) { char c; c=getchew ( ); printf(―%c‖,c); }

“ get char( )”

It is a c standred library function that gets a single character from key Borad.Get character does not gets the input untile after you press enter key. Ex:- Main( ) { int A; printf(―the character %c‖,a); printf(―correspends to the a%d‖,a);

“Put char( )”

Syntax:- put char(c ); The put character function will write its character argament to the screan.

“gets”

It gets a requance of characters from key Borad.Which are stored in the variable gets allows the user to use the back space key to corree any error whole Entering the letters Ex. Main ( ) { char c; gets ©;

“ Puts ©”

Puts(―in the print valu is‖,c) “puts” syntax:- puts © puts only outputs a string of characters on the screan but it canot out put no. or do format conversions these for when displaying strings puts taker up less space as com[aised to printf statement.

“Loop”

Loop:- Loop is a opeating some portion of the program either a specinfied number of times or until a porticular condition is being satisfied.There are three methods 1. for statement. 2. while statement. 3. do while statement.

Leave a Reply

Your email address will not be published. Required fields are marked *