Thursday, August 30, 2012

Data types and names in c

The char data type: An object of char data type represents a single character e.g a, b, d, A, F, D, 5,9 &,%,( etc.
computer can only store numeric code, therefore characters such as A, a, B, b and so on all have a unique numeric code that is used by computers to represent the characters. For many computers, the ASCII codes are the standard code that is used by the computer to represent a character set.

Character Variable: A variable that can represent different characters is called the character variable.
e.g char sann;
or char sann, s1, s2, stdnt; (you can define more than one characters in single line as shown here).

To print a character we use character format specifier %c, which indicates to printf() function that the argument to be printed is a character.

#include<stdio.h>
#include<conio.h>
void main()
{
char c1='a';
char c2='5';
printf("output: %c",c1);
printf("output: %c",c2 );
getch();
}

The int data type: The int keyword is used to specify the type of a variable as an integer. Integer numbers are also called the whole numbers.

Declaring integer variables:
int variablename;(basic declaration format).
or int variablename1, variablename2, variablename3;

int type:

type                    size(byte)               minimum value               maximum value           format specifer

short int                 2                            -2^15                             2^15-1                       %hd
int                         2                            -2^15                             2^15-1                        %d
long int                  4                            -2^31                             2^31-1                        %ld
long long int           8                            -2^63                             2^63-1                        %lld

Real numbers: The real type holds the values that consists of an integral part and fractional part such as 56.908. there are three different size of real types.
(i) float (4 byes, %f, precision 6 digits) (ii) double (10 bytes, %f, precision 10 digits) (iii) long double (10 bytes, %Lf, precision 10 digits).

variable declaration:
float price;
long double radius;
double a;













Friday, August 24, 2012

the basics of c program

As a building is made of bricks, a c program is made of basic elements such as expressions, statements, statement blocks, constants, and variables.

constants and variables: A constant is a value that never changes while a variable can be used to present different values.
ex. i=1, symbol '1' represents the constants and symbol 'i' represents the variable.

Expressions: An expression is combination of constants, variables and operators that are used to denote the computations.

for ex: (4+8)*6-i+7.

C-Arithmetic operator: 
symbol                    meaning
+                           addition
-                            subtraction
*                           mmultiplication
/                            division
%                         remainder 

Statements: A statement is a complete instruction, ending with a semicolon.
e.g i=8;

Statement Blocks: A group of statements can form a statement block that starts with an opening brace ({) and ends with a closing brace (}).
e.g {
s4=9-7;
s3=s4+i;
   .
   .
   .
    }

Tuesday, August 7, 2012

what is c programming language

C is a programming language. The C language was first developed in 1972 by Dennis Ritchie at AT & T (American Telephone and Telegraph company) Bell labs.
C is a high level programming language because it is closer to human language. While the lowest languages are machine language that computer understand directly.
Example: The human language: "if line is not busy connect to the internet".
High level language: if(line != busy) connect( internet).
The machine language: 1001010100101111000011111010101010