Related to C programmingxzxzc

 

#include <stdio.h>

int main() {

  char a =3D ‘a’;

  printf(“Size
of char : %d\n”
,sizeof<sp= an style=3D’font-size:10.0pt;font-family:Consolas;mso-fareast-font-family:”Tim= es New Roman”; color:#303336;background:#EFF0F1′>(a));

  printf(“Size
of char : %d\n”
,sizeof<sp= an style=3D’font-size:10.0pt;font-family:Consolas;mso-fareast-font-family:”Tim= es New Roman”; color:#303336;background:#EFF0F1′>(‘a’));

  return 0;

}

<sp= an style=3D’font-size:11.5pt;font-family:”Arial”,sans-serif;mso-fareast-font-f= amily: “Times New Roman”;color:#005999′>Output:

Size of char : 1

Size of char : 4

In C, the type of a
character constant like 
'a' is actually an <cod= e>int, with size of 4 (or some other
implementation-dependent value). In C++, the type is 
char, with size of 1. This is one of many small
differences between the two languages.

 

Conversions

If x is float and i is an int, then x=3D<sp= an class=3DSpellE>i and i=3Dx both cause co=
nversions

Float to int
causes truncation of any fractional part

When double is converted=
to
float, whether value is truncated or rounded is implementation <= /span>

Dependent.

 =

Bitwise  <= /span>operators

x=3D1 y=3D2

x&y=3D0

x&&y=3D1

x<<2 leftshift by 2

x>>3 right shift b=
y 3

 =

left shift fills vacated bits with zeros

right shift of unsigned fills vacated bits  with zeros

left shift of signed  fills vacated bits with sign bit in some
machines and 0’s in some other machines

 =

 =