Monday, February 11, 2013 #


       C HAS TWO USEFUL OPERATOR INCREMENT (++) AND DECREMENT (- -) These are the unary operator because these operate on only single operand
     The increment operator (++) increment the value of the variable by 1 and decrement operator (- -) decrement   the value of the variable by 1 we can write this as –
++a or a=a+1
- - a or a=a-1
These operator   are of two types
1.Prefix increment /decrenment
 Here ,first the value of variable is incremented/decremented then the value  of variable is taken for operation.
 Let us take the value of a =3
Then the statement b=++a ; means first increment the value   of ‘a’ by 1 then ‘b’takes the value of ‘a’
Hence a=4          b=4
 The statement b=- -a; ,means first decrement the values of ‘a’ by 1 then ‘b’ tekes   the values of ‘a’
Hence a=3             b=3
 /* program to understand   the use of prefix increment /decrement*/
Void main( )
 Int a=3;
Printf(“a= %d\n”,++a)        */prefix increment*/
Printf(“a=\n”,- -a);                 /* prefix decrement*/                                               
Printf(“ a=%d\n”,a);
2.postfix increment /decrement
 Here , first the value of variable is taken   for operation then value of variable is increment /decremented.
a- -
 Lets us take the value of a=3
 Then the statement b=a++ ;means first ‘b’ take   the value of ‘a’ then increment it b y 1.
Hence a=4    b=3
 The statement b=a- - means first ‘b’ takes the value of ‘a’ then decrement it by 1.
Hence a=3   b=4
 /*program to  understand the use of prefix increment / decrement */
# include<stdio .h>
Void main( )
Int a =3;
Printf( “a=%d\n”,a++);/*postfix increment*/
Printf(“a=%d\n”a- -);

posted @ Monday, February 11, 2013 5:35 PM | Feedback (0)

Tuesday, December 18, 2012 #

logical or Boolean operator

Logical or Boolean operator

    An expression that combines two or more expression s termed as a logical expression .

For combining these expression we use the logical operator .aftter testing   the values of the condition (which is rue or false), it gives the logical   status (true or false) as a net result.

The   oerand may be constant ,variable and expression .C has three logical   operator-

Operator                       meaning
&&                                     AND
||                                          OR
!                                           NOT

       This operator gives the net result true if the condition have the values true ,otherwise gives the result false.

Boolean Table
Condition 1            condition 2               result
False                              false                  false
False                              true                    false
True                                false                  false
True                                 true                   true
Let a=10 and b=5
The logical expression   is-
A==10 && b<a

   This gives the result true because both the condition a==10 and b<a

 Is true and gives the net result true-
OR(||) operator-

     This operator gives the  net   result    false .if both the condition. Have the value false .otherwise it gives the result true.

Boolean table
Condition 1       condition2            result
False                      false                 false
False                      true                   true
True                      false                    true
True                      true                      true
Ex- let us take the value of two variable a=7 and b=12

 The   logiacal expression is


 This gives the result true because one condition  is true   and gives     the net result true.

NOT (!) operator-

 This is a unary operator   this negates the value   of the condition .if the value of the condition is false then it gives   the result true . if the value of   the condition is true it gives   the result false  .

Boolean  table
Condition       Result
False                  true
True                    false
Let us take any variable a=10
These logical expression is
The value of the condition is true .NOT operator negates the value of the condition .Hence the result is false.

posted @ Tuesday, December 18, 2012 4:45 PM | Feedback (0)

Friday, December 14, 2012 #

what is Relational operator in C?

Relational operator
    Relational oprerator are used   to compare two values depending on their   relation .two operands.

 An expression that then contain the relational operator is called relational expression . if the relation is true then it return s the values1, if the relation   is false then it return the value 0. These operators are-

Operator                                  Meaning
<                                               less than

<=                                             less than or equal to

==                                              equal

!=                                                not equal

>                                                 greater then

>=                                               Greater than or equal

Let a=9 and b=5, then the operation with relational operator are-
Expression                                result

a<b                                             false(0)

a<=b                                           false (0)

a==b                                           false(0)

a!=b                                             true(1)
a>b                                              true(1)

a>=b                                            true(1)

/* program to understand the use of relational operator*/
 Void main()
Int a,b;

Printf(“ enter first number for a :”);

Scanf(“%d”,&a) ;
Printf(“enter the second number for b”);
Scanf( “%d”,&b);
If(a<b)/* relational operator with if (in control statement)*
Printf(“%d is less than %d\n”,a,b);
If(a<= b)
Printf(“%d is less or equal to %d\n”,a,b);
Printf(“%d is equal to %d\n”,a,b);
If(a !=b)
Primntf(“%d is not equal to %d\n”,a,b);
If (a>b)
Printf(“%d is greater than %d\n”,a,b);
If (a>=b)
Printf(“%d is greater or equal to %d \n”,a,b);
After run :
First number for a:12
Second number for b:7
12 is not equal to 7
12 is greater than 7
12 is greater or equal to 7    

posted @ Friday, December 14, 2012 4:06 PM | Feedback (0)

Wednesday, December 12, 2012 #

floating point arithmetic

Floating point arithmetic
      When both the operands are of float type then the arithmetic   operation with these operands is called Floating point arithmetic.
Ex- Let us take two variables a and b . The values a=12.4 and b=3.1 . The result of these operation are as –
Expression         result
a+b                       15.5
a-b                         9.3
a*b                        38.44
a/b                          4.0
 The modulus operator % can not beused with floating point numbers.
/* program to understand  the floating point arithmetic operation*/
#include <stdio.h>
Void main( )
Float a=9.6,b=1.6;
Printf(“ after addition :%f\n”,a+b);

Printf(“after subtraction :%f\n’,a-b);

Printf(“after division:%f\n”a/b);

Printf(“after multiplication :%f\n”a*b)

After addition : 11.2
After subtraction:8.0
After division: 6.0
After multiplication: 15.36

posted @ Wednesday, December 12, 2012 4:19 PM | Feedback (0)

Wednesday, December 5, 2012 #

integer arithmetic

Integer arithmetic
 When both operands are integer then the arithmetic operation with these operand is called integer arithmetic.

    Let us take two variable a and b. The value of a =17 and b=4 then the result of these operation are –

 Expression                          result
a+b                                          21
a-b                                          13
a*b                                          68
a/b                                           4
a%b                                         1

    after division operation the decimal   part will be truncated and result is only   integer part of quotient .after  modulus operation the result will be remainder part of integer division.

   It is necessary  fo division and modulus operation that second operand must be nonzero.

1.Program to understand the integer   arithmetic operatin .

Void main( )
Int a=17,b =4;
Printf(“after addition :%d\n”,a+b);
Printf(“after subtraction :%d\n”a-b);
Printf(‘after division :%d\n”a/b);
Printf(“after modulus :%d\n”,a %d);
After addition :21
After subtraction :13
After multiplication :68
 After division:4
After modulus:1

posted @ Wednesday, December 5, 2012 4:42 PM | Feedback (0)

Saturday, December 1, 2012 #

OPerator & Expression

 operator & Expression  

An operator specifies an operator to be perfomed that yield a valueThe variable   constant can be joined by various operator to form an expression .an operand is a data item on which an operator acts .some operator requires  two oprend s,while other act upon only ane operand .C includes a large number   of operend which fall under several different catogories ,which are as –

1.Arithmetic operator
2.Relational operator
3.logical operator
4.Assignment operator
5.Ternary operator
6.Bitwise operator
7.increment or Decrement operator

Arithmetic operators are used for numeric calculation .They are two types

1.unary arithmetic
2.binary arithmetic
1.unary arithmetic
 +x –y
Here ‘-‘ changes the sign of the operand y.
2.binary arithmetic
 it require two operand .There are five operators   for binary arithmetic.

Operator           meaning                purpose
+                           plus                         addition
-                            minus                      subtraction
*                            asterisk                    multiplication
/                           slash                           division
%                          percent                        division

%(modules operator ) cannot be applied with floating point number .There is no exponent operator in ever there is a library function to carry out exponent.






Here ‘a’ and ‘b’ are two operands

posted @ Saturday, December 1, 2012 5:21 PM | Feedback (1)

Tuesday, November 27, 2012 #

format for string output

format for string out put.
 Where w is the total number of characters in the string .Decimal point and ‘n’ are option if present than the (w-n) leading blanks are displayed before string .

(i)                 Printf( “%3s”, Rajes kumar”);

Rajes kumar
Result :
Reeta (w-length of string leading blanks)
(ii)printf(“%3s”,rajes kumar”);
(iii)Printf(“%8.3s”,rajesh kumar”);
- - - - -raj
(8-3=5 leading blanks)
Note – if we want to skip any   inpurt field then we specify * in the place of the field width.
 Then 25 is stored in ‘a’ ,30 is skipped and 35 is stored in the ‘b’ since no data is available for ‘c’ so it takes garbage value.
/ * program to understand this pint */
#include <stdio.h>
Int a,b,c;

 Printf ( “enter the three number:”);

Scanf(“%d %*d %d”, &a,&b&c);
Printf(“%d %d %d”,a,b,c);
 Input :
 25, 30, 35
Out put:
25 35 25381(garbage value)

posted @ Tuesday, November 27, 2012 5:03 PM | Feedback (0)

Friday, November 23, 2012 #

format for floating point numeric input

  3.format for floating point numeric input
%w.n f
Where w is the integer number specifying the total width of the input data and n spefies number of digits after decimal point .
Scanf(“%3.11 %4.2f “,&a,&b);
(1) When input data length is less then the given length then the given values are unaltered and tored in the given variable .
Input: 5 5.9
Result :
5.0 is stored in a and 5.90 is stored in b.
(ii) when input data length is equal to the given length then the given values are unaltered and stored in the given variable .
5.3.5 92
Result: 5.3 is stored in a and 5.92 is stored in b.
(iii) when input data length is more than the given length then the give n values are altered and stored in the given variable as –
Input : 5.93 65.875
Result: 5.9 is stored in a and 3.00 is stored in b.

1. Format for floating point numeric output .
Where w is the integer number specifying the total width of the input data and n is the number of digits after decimal point.
Ex-printf(“%3.1 f %4.2 f”,a,b);
Printf(“%3.1f %4.2f”,a,b)
(i)When output data length is less than the given input data length
Input: 5 5.9
5.0 5.90
(ii) when output data length is equal to the data length
Input;5.3 5.92
5.3 5.92
(iii) when output data length is more than the given input length then digits after decimal point are truncated.
5.93 65.875
5.9 65.8
5.format for string input
Where w is the total number of characters in the string,decimal point and ‘n’ are optional .If present then (w-n) number of loasing blanks are interested before string.
char str[8]
scanf (“%7s”,str);
(i)when input string less than then the size of the arry
‘m’ ‘a’ ‘n’ ‘j’ ‘u’\ 0 is stored in array str .
‘\0’ is automatically placed at the end of the string.
(ii) When the input string is equal to the size of the array.
Input : sanjeev
Result :
‘S’ ‘a’’n’ ‘j’ ‘e’ ‘e’ ‘v’ \0 is stored in array str
(iii) When the length of the input string is more tha n the size of the arrary then it can store the garbage value.

posted @ Friday, November 23, 2012 5:34 PM | Feedback (0)

Wednesday, November 21, 2012 #

formated input and out put data

Formated input and out put

Formatted input means that data is arranged   in a particular   format and formatted out means that the out put is displayed in such a way that   they are in understandable and easy –to –use form .So we c an say that through format specification better presentation of result can be obtained .Formats for different specifiaction are as –

1.Format for integer 

Where w is an integer number specifying   the width of input data. ‘d’ is the conversion specification character for integer   value.

Scanf(“%2d %3d”, &a,&b);
(i)When input data length is less than the given length ,Then   the given values are unaltered and stored and stored in given variables
26  39

26 is stored in a and 39 is stored in b

(ii) When input data length is equal   to the given length, then the given values are unaltered and                     
 Stored in given variables.      
26   394
26 is stored in a and 394 is stored in b
3) when input data length is more    than the given legth, then the given values are altered and stored   in the variable as –
 Input :
269 3945
 Result :
26 is stored in a and 9 is stored in b .
2.formated for integer out put.

 Where   w is the integer number specifying the width of the output data

 Printf ( “a= 52d b= %3d”,a,b);
Condition –
(1)   Whene out put data is less than the gib=ven input data length input :
26 39
Result :
A=26 b= -39

 Here the second data has one leading   blank (w-number of digits in b)

(ii) Whene out put   data lenghth is equal to the input d ata length   input:

26 394
 Out put :
A=26 b= 394

(iii) when put put   data length is more than   the input data length 

269 3945
Out put:
a=269 b= 3945

posted @ Wednesday, November 21, 2012 4:54 PM | Feedback (0)

Friday, November 16, 2012 #

writing out put data in C

Writing  out put data

    Out put data  can be  written  from  computer  memory to the standard  output  device (monitor) or to  another  file .C  provides  the  printf( ) library function  for  writing  output  data .with   this  function  all type  of  values(numeric character  or string) can be  written  as output .The  printf( ) function  moves  data  from  computer  m emory  to the standard  output  device ,,whereas  scanf() function  takes  the  input  data from  standard  input  device  and store   it to the  computer  memory. The printf function can be  written  as -

Print(“control  string  “, variable 1,variable2………) 


In this  function  the control  string  has  string (text) with coversion specification  character .It  should  be enclosed  with  double  quotes . the  variable  names  are optional  in the  printf() function  . the variable  name  should  not be  prceded  with ampersand(&).

 Some example  of  printf() function are as-



main( )


printf(“c is excellent”);



out put :

C is excellent


Here  control string  has only  text and no  conversion  specification character  ,hence  the  output  is only  text-


#include <stdio.h>

main( )


int basic ;



printf (“%d”,basic);


 in the  example  control  string  has  conversion  specification  character  %d which  implies  that  integer value  will be  displayed  and the  variable  name  basic  has that  integer- value  which  will  displayed  as output.


Ex- 3

#include  <stdio.h>

main( )


float  height ;



printf(“%f “,height);



here control  has  conversion specification character  % f which  means  that  floating  point  number  will be  displayed  and  the variable  name  height  has that floating  point value which will  be displayed  as output.


It will continue in next  blog




posted @ Friday, November 16, 2012 5:51 PM | Feedback (0)

Advertisements at

Copyright © Afsana Bano

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski