We can initialize variables with different type.I run a program for it which has following codes:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a1=5;
int a2='5';
int a3=5.5; //intialising with double value
int a4=5.5f; //initialising with float value
int a5=5.5F; //initialising with float value
int a6=5.5l; //double
int a7=5.5L; //long double
int a8=0xff; int a8a=0xffffffff; int a8b=0xfff; int a8c=0xffff;
int a9=0xFF;
int a10=0123; //Octal int a=06; //octal
printf("a=%d\n",a1);
printf("a2=%lf\n",a2); // double
printf("a3=%f\n",a3); //float
printf("a4=%f\n",a4); //float
printf("a5=%lf\n",a5); //double
printf("a6 =%Lf\n",a6);//long double
printf("a7 =%Lf\n",a7);//long double
printf("a8 =%Lf\n",a8);//long double
printf("a8a =%Lf\n",a8a);//long double
printf("a8b =%Lf\n",a8b);//long double
printf("a8c =%Lf\n",a8c);//long double
printf("a9=%Lf\n",a9);//long double
printf("a10 =%Lf\n",a10);//long double
auto a=2; //auto
auto b=3.8; //double
auto b1=3.8f; //float
auto b2=3.8F; //float
auto b3=3.8l; //double
auto b4=3.8L; //long double
auto c='h'; //char
printf("a=%d\n",a);
printf("b=%lf\n",b); // double
printf("b1=%f\n",b1); //float
printf("b2=%f\n",b2); //float
printf("b3=%lf\n",b3); //double
printf("b4 =%Lf\n",b4); //long double
printf("c =%c\n",c); //char
char a12='a';//char
char a13=20;//int
char a14='\x40';//hex
char a15='\45'; //octal
char a16='\u0040'; //unicode 16 bit
char a17='\U00000040'; //unicode 32 bit
printf("a12=%c\n",a12);
printf("a13=%c\n",a13);
printf("a14=%c\n",a14);
printf("a15=%c\n",a15);
printf("a16=%c\n",a16);
printf("a17=%c\n",a17);
char* a18="abdb";
char* a19="\x0040"; char* a20="\x40\xff";
char* a21="\334"; char* a22="\334\100";
char* a23="\u00ff"; char* a24="\u00ff\u00ff";
char* a25="\U000000F6"; char* a26="\U000000F6\U000000F6";
char*a59="\U000000F6\u00ff\x10\100";
printf("a18=%s\n",a18);
printf("a19=%s\n",a19);
printf("a20=%s\n",a20);
printf("a21=%s\n",a21);
printf("a22=%s\n",a22);
printf("a23=%s\n",a23);
printf("a21=%s\n",a24);
printf("a22=%s\n",a25);
printf("a23=%s\n",a26);
printf("a59=%s\n",a59);
wchar_t a27='a';
wchar_t a28=L'a';
wchar_t a31=20;
wchar_t a32='\x40';
wchar_t a35=L'\x79';
wchar_t a36='\33'; wchar_t a37='\51'; wchar_t a38=L'\334'; wchar_t a39=L'\51';
wchar_t a40='\u00ff'; wchar_t a41='\u00ff'; wchar_t a42=L'\u00ff'; wchar_t a43=L'\u00ff';
wchar_t a44='\U000000F6'; wchar_t a45='\U000000F6'; wchar_t a46=L'\U000000F6'; wchar_t a47=L'\U000000F6';
wprintf(L"a27=%lc\n", a27);
wprintf(L"a28=%lc\n", a28);
wprintf(L"a31=%lc\n", a31);
wprintf(L"a32=%lc\n", a32);
wprintf(L"a35lc=%lc\n", a35);
wprintf(L"a36=%lc\n", a36);
wprintf(L"a37=%lc\n", a37);
wprintf(L"a38=%lc\n", a38);
wprintf(L"a39=%lc\n", a39);
wprintf(L"a40=%lc\n", a40);
wprintf(L"a41=%lc\n", a41);
wprintf(L"a42=%lc\n", a42);
wprintf(L"a43=%lc\n", a43);
wprintf(L"a44=%lc\n", a44);
wprintf(L"a45=%lc\n", a45);
wprintf(L"a46=%lc\n", a46);
wprintf(L"a47=%lc\n", a47);
wchar_t* a48=L"a"; wchar_t* a49=L"abdsf";
wchar_t* a50=L"\x40"; wchar_t* a50a=L"\x1079";
wchar_t* a51=L"\x7910\x1879\x7979\x0056";
wchar_t* a52=L"\333"; wchar_t* a53=L"\333\33\333";
wchar_t* a54=L"\u00ff"; wchar_t* a55=L"\u00ff\u00ff";
wchar_t* a56=L"\U000000F6"; wchar_t* a57=L"\U000000F6\U000000F6";
wchar_t*a58=L"\U000000F6\u00ff\x1079\x10\345tyur1233$#%";
wprintf(L"*a48=%s\n", a48);
wprintf(L"*a49=%s\n", a49);
wprintf(L"*a50=%s\n", a50);
wprintf(L"*a50a=%s\n", a50a);
wprintf(L"*a51=%s\n", a51);
wprintf(L"*a52=%s\n", a52);
wprintf(L"*a53=%s\n", a53);
wprintf(L"*a54=%s\n", a54);
wprintf(L"*a55=%s\n", a55);
wprintf(L"*a56=%s\n", a56);
wprintf(L"*a57=%s\n", a57);
wprintf(L"*a58=%s\n", a58);
_getch();
}
Output:-
a=5
a2=0.000000
a3=0.000000
a4=0.000000
a5=0.000000
a6 =0.000000
a7 =0.000000
a8 =0.000000
a8a =0.000000
a8b =0.000000
a8c =0.000000
a9=0.000000
a10 =0.000000
a=2
b=3.800000
b1=3.800000
b2=3.800000
b3=3.800000
b4 =3.800000
c =h
a12=a
a13=¶
a14=@
a15=%
a16=@
a17=@
a18=abdb
a19=@
a20=@
a21=▄
a22=▄@
a23=
a21=
a22=÷
a23=÷÷
a59=÷ ►@
a27=a
a28=a
a31=¶
a32=@
a35lc=y
a36=←
a37=)
a38=▄
a39=)
a40=?
a41=?
a42=
a43=
a44=?
a45=?
a46=÷
a47=÷
*a48=a
*a49=abdsf
*a50=@
*a50a=?
*a51=???V
*a52=█
*a53=█←█
*a54=
*a55=
*a56=÷
*a57=÷÷
*a58=÷ ?►σtyur1233$#%
Following intialization has their own meaning:-
'\ooo': char with octal value
'\xhh':char with hex value
'\u':16-bit, assumed UTF16
'\U'-32-bit, assumed UCS-4
*L is used for declare a wide character literal or wide char string literal.
#include<stdio.h>
#include<conio.h>
void main()
{
int a1=5;
int a2='5';
int a3=5.5; //intialising with double value
int a4=5.5f; //initialising with float value
int a5=5.5F; //initialising with float value
int a6=5.5l; //double
int a7=5.5L; //long double
int a8=0xff; int a8a=0xffffffff; int a8b=0xfff; int a8c=0xffff;
int a9=0xFF;
int a10=0123; //Octal int a=06; //octal
printf("a=%d\n",a1);
printf("a2=%lf\n",a2); // double
printf("a3=%f\n",a3); //float
printf("a4=%f\n",a4); //float
printf("a5=%lf\n",a5); //double
printf("a6 =%Lf\n",a6);//long double
printf("a7 =%Lf\n",a7);//long double
printf("a8 =%Lf\n",a8);//long double
printf("a8a =%Lf\n",a8a);//long double
printf("a8b =%Lf\n",a8b);//long double
printf("a8c =%Lf\n",a8c);//long double
printf("a9=%Lf\n",a9);//long double
printf("a10 =%Lf\n",a10);//long double
auto a=2; //auto
auto b=3.8; //double
auto b1=3.8f; //float
auto b2=3.8F; //float
auto b3=3.8l; //double
auto b4=3.8L; //long double
auto c='h'; //char
printf("a=%d\n",a);
printf("b=%lf\n",b); // double
printf("b1=%f\n",b1); //float
printf("b2=%f\n",b2); //float
printf("b3=%lf\n",b3); //double
printf("b4 =%Lf\n",b4); //long double
printf("c =%c\n",c); //char
char a12='a';//char
char a13=20;//int
char a14='\x40';//hex
char a15='\45'; //octal
char a16='\u0040'; //unicode 16 bit
char a17='\U00000040'; //unicode 32 bit
printf("a12=%c\n",a12);
printf("a13=%c\n",a13);
printf("a14=%c\n",a14);
printf("a15=%c\n",a15);
printf("a16=%c\n",a16);
printf("a17=%c\n",a17);
char* a18="abdb";
char* a19="\x0040"; char* a20="\x40\xff";
char* a21="\334"; char* a22="\334\100";
char* a23="\u00ff"; char* a24="\u00ff\u00ff";
char* a25="\U000000F6"; char* a26="\U000000F6\U000000F6";
char*a59="\U000000F6\u00ff\x10\100";
printf("a18=%s\n",a18);
printf("a19=%s\n",a19);
printf("a20=%s\n",a20);
printf("a21=%s\n",a21);
printf("a22=%s\n",a22);
printf("a23=%s\n",a23);
printf("a21=%s\n",a24);
printf("a22=%s\n",a25);
printf("a23=%s\n",a26);
printf("a59=%s\n",a59);
wchar_t a27='a';
wchar_t a28=L'a';
wchar_t a31=20;
wchar_t a32='\x40';
wchar_t a35=L'\x79';
wchar_t a36='\33'; wchar_t a37='\51'; wchar_t a38=L'\334'; wchar_t a39=L'\51';
wchar_t a40='\u00ff'; wchar_t a41='\u00ff'; wchar_t a42=L'\u00ff'; wchar_t a43=L'\u00ff';
wchar_t a44='\U000000F6'; wchar_t a45='\U000000F6'; wchar_t a46=L'\U000000F6'; wchar_t a47=L'\U000000F6';
wprintf(L"a27=%lc\n", a27);
wprintf(L"a28=%lc\n", a28);
wprintf(L"a31=%lc\n", a31);
wprintf(L"a32=%lc\n", a32);
wprintf(L"a35lc=%lc\n", a35);
wprintf(L"a36=%lc\n", a36);
wprintf(L"a37=%lc\n", a37);
wprintf(L"a38=%lc\n", a38);
wprintf(L"a39=%lc\n", a39);
wprintf(L"a40=%lc\n", a40);
wprintf(L"a41=%lc\n", a41);
wprintf(L"a42=%lc\n", a42);
wprintf(L"a43=%lc\n", a43);
wprintf(L"a44=%lc\n", a44);
wprintf(L"a45=%lc\n", a45);
wprintf(L"a46=%lc\n", a46);
wprintf(L"a47=%lc\n", a47);
wchar_t* a48=L"a"; wchar_t* a49=L"abdsf";
wchar_t* a50=L"\x40"; wchar_t* a50a=L"\x1079";
wchar_t* a51=L"\x7910\x1879\x7979\x0056";
wchar_t* a52=L"\333"; wchar_t* a53=L"\333\33\333";
wchar_t* a54=L"\u00ff"; wchar_t* a55=L"\u00ff\u00ff";
wchar_t* a56=L"\U000000F6"; wchar_t* a57=L"\U000000F6\U000000F6";
wchar_t*a58=L"\U000000F6\u00ff\x1079\x10\345tyur1233$#%";
wprintf(L"*a48=%s\n", a48);
wprintf(L"*a49=%s\n", a49);
wprintf(L"*a50=%s\n", a50);
wprintf(L"*a50a=%s\n", a50a);
wprintf(L"*a51=%s\n", a51);
wprintf(L"*a52=%s\n", a52);
wprintf(L"*a53=%s\n", a53);
wprintf(L"*a54=%s\n", a54);
wprintf(L"*a55=%s\n", a55);
wprintf(L"*a56=%s\n", a56);
wprintf(L"*a57=%s\n", a57);
wprintf(L"*a58=%s\n", a58);
_getch();
}
Output:-
a=5
a2=0.000000
a3=0.000000
a4=0.000000
a5=0.000000
a6 =0.000000
a7 =0.000000
a8 =0.000000
a8a =0.000000
a8b =0.000000
a8c =0.000000
a9=0.000000
a10 =0.000000
a=2
b=3.800000
b1=3.800000
b2=3.800000
b3=3.800000
b4 =3.800000
c =h
a12=a
a13=¶
a14=@
a15=%
a16=@
a17=@
a18=abdb
a19=@
a20=@
a21=▄
a22=▄@
a23=
a21=
a22=÷
a23=÷÷
a59=÷ ►@
a27=a
a28=a
a31=¶
a32=@
a35lc=y
a36=←
a37=)
a38=▄
a39=)
a40=?
a41=?
a42=
a43=
a44=?
a45=?
a46=÷
a47=÷
*a48=a
*a49=abdsf
*a50=@
*a50a=?
*a51=???V
*a52=█
*a53=█←█
*a54=
*a55=
*a56=÷
*a57=÷÷
*a58=÷ ?►σtyur1233$#%
Following intialization has their own meaning:-
'\ooo': char with octal value
'\xhh':char with hex value
'\u':16-bit, assumed UTF16
'\U'-32-bit, assumed UCS-4
*L is used for declare a wide character literal or wide char string literal.
No comments:
Post a Comment