Posts

Showing posts from April, 2012

Basic Input Output

Image
Basic input/output:- Input refers to accepting data from outside the program to the program while output refers to presenting the programmed data as a result of programming. Every program performs three main functions accepting data from user, processing it and producing the output. In C language there are several input and output functions.These functions are collectively found in  "IO.h" and such IO function together form a library name "stdio.h" .User will require all such library function. These library functions are classified into three broad categories: 1. Console I/O functions:- Console I/O refers to the operation that occur at the keyboard and the screen of your computer . Different streams are used to represent different kinds of data flow. In C there are 3 streams associated with console I/O operations. These are:- Stdin:-   It is the stream which supplies the data from input sources(i.e keyboard) to progr...

Expression in C

Expression:- An expression is a combination of variables, constants and operators arranged according to the syntax of the language. C can handle any complex expression with ease. It is little bit different from algebraic expression. Algebraic Expressions C Expressions axb-cxd a*b-c*d (m+n)(a+b) (m+n)*(a+b) Evaluation of expression: We can evaluate an expression by using assignment statement. As:- Variable = Expression. e.g. : Temp = ((f * cos(x)/sin (y))+(g * sin(x)/cos(y))) All relevant variables must be assigned values before the evaluation of the expression. Type conversion in expression:- To effectively develop C programs, it would be necessary for you to understand the rules that are used for the implicit conversion of operands. If an expression contains an operation between an int and a float, the int would be automatically promoted to a float before carrying out of operation. Automatic type conversion:- If the operands are o...

Instruction set in C

Instruction is the command formed by the grouping of constants, variables & keywords. It tells the compiler what to do. There are basically four types of instruction in C. 1. Type Declaration Instruction:-This type of instruction is used to declare the type of variable being used in the program. Any variable used in the program must be declared before using it in any statement.This instruction is usually written at the beginning of the C program. e.x.: int i; char nm,d. 2. Input Output instruction:- These instructions are used to supply input data to a program and obtain the output results from it. e.x.: printf(), scanf(). 3. Arithmetic Instructions:- These types of instructions are used to perform arithmetic operations between constants and variables.Some of the arithmetic operators are: +, -, * and /. e.x.: int a; float b,de,al,ga,be; a=500; b=0.0056; d=al*be/ga+0.5*2/5; There are three types of arithmetic statements: i.Integ...

Operators in C

Operators:- C has a lot of built-in operators.Operators are symbols, which are use to operate or manupulate operands.There are various types of operators:- 1.Arithmetic operators:- Arithmetic Operators are used for Arithmetical calculation. There are five Arithmetic operators in C: Operator Purpose + Addition - Subtraction * Multiplication / Division % Remainder after integer division 2.Relational operators:- Relational operators are used to compare two operands and to check whether they are equal, unequal, greater than and lesser than other. There are 6 relational operators: Operator Meaning < Less than > Greater than <= Less than equal to >= Greater than equal to == Equal to != Not equal to The value of the relational o...

Backslash character constants

Image
Enclosing character constants in single quotes works for most printing characters.A few , however, such as carriage return, can't be. For this reason, C includes special backslash character constants, so that you may easily enter these special characters as constants. You should use the backslash codes instead of their ASCII equivalents to help insure portability. List of backslash character constants are as follows:- Code Meaning \b Backspace \f Form feed \n New line \r Carriage return \t Horizontal tab \" Double quote \' Single quote \\ Backslash \v Vertical tab \a ...

Variables

Image
As you know, "A variable is a named location in memory that is used to hold a value that can be modified by the program". All variables must be declared before they can be used. Variable declaration:- General form of declaring a variable is:- "type variable_list;" here "type" is the data type you want to use and variable_list is the name of identifiers(variable/varibles). e.x:- int i; here i is name of variable of integer type. int a,bcd,c_i; here a,bcd,c_i are names of variables of integer type. Types of variables:- 1.Local variables:- These are the variables declared inside a function. These are also called as "automatic variable". It can be used only from inside the program i.e it can be used only by the statements that are inside the block in which the variables are declared. e.x. - void func(void) { int a; <- here a is a integer type variable which is locally declared. a=20; } 2.Global variables:- These a...

Basic data types

Image
There are basically 5 data types : 1.Character:- It can be declared using "char".It takes 1 Byte(8 bits) of memory space. These types of variables are generally used to hold values defined by the ASCII character set i.e. any single character. Its minimal range is from -127 to 127. 2.Integer:- It can be declared using "int". It takes 2 Bytes(16 bits) of memory space. These types of variables are generally used to hold numerical values. It doesn't support the digits after decimal. Its minimal range is -32,767 to 32,767. 3.Floating point:- It can be declared using "float". It takes 4 Bytes(32 bits) of memory space. These types of variables are generally used to hold numerical values. It supports upto 6 digits after decimal. Its minimal range is from 1E-37 to +37. 4.Double:- It can be declared using "double". It takes 8 Bytes(64 bits) of memory space. These types of variables are generally used to hold numerical values. It supports upto...

Components of C language

Image
There are five main component of C language :- 1. The character set: Any alphabet ,digit or special symbol ,used to represent information is denoted by character. The character in C are grouped into four categories:- i) Letters A...Z and a...z ii) Digits 0,1,2,.....9 iii) Special Symbol ~ ` ! @ # $ % ^ & * () . < > ? / " : ; { }[ ]. iv) White Space,blank space, Carriage return, form feed, newline, horizontal tab. C uses the uppercase letter A to Z, the lowercase letters a to z, the digits 0 to 9, and certain special characters as building blocks to form basic program elements ( e.g., constants, variables, operators, expressions, etc. Some of the special characters are listed below: + - * ~ % / & ( ) { } [ ] ? " < > ! ; : Most versions of the language also allow certain other characters, such as @ and $, to be included within strings and comments. C uses certain combinations of these characters, such as \b,\n and \t, to represent spe...

What is C programming language?

Image
C is a programming language developed by "Dennis Ritchie" at AT & T's lab of USA in 1972. It gives us basic programming skills, problem solving technique and concept to write a program. It is very powerful programming language, still today. It is a middle level programming language that is able to manipulate the computer at a low level like assembly language. During the last half of the 1980s, it became the language of choice for developing commercial software. It is the most commonly used programming language for writing system software, though it is also widely used for writing applications. C, and its object-oriented successor C++, are used to write a huge variety of applications and almost all operating systems. Some of the advantages of C language are:- It provides predefined header files and keywords. It provides declaring different types of data variables. It provides flexibility and simplicity, so it can be easily learned. C provides several language element...