1. Char Data Type & Number System.
#include<stdio.h>
void main()
{
int question;
char CSK;
unsigned char UCSK;
printf("---- Solutions of Char Data Type ----\n");
while(1)
{
printf("Enter question number : ");
scanf("%d",&question);
switch(question)
{
case 1:
CSK=0xCC;
printf("%d\n",CSK);
break;
case 2:
CSK=0xFB;
printf("%d\n",CSK);
break;
case 3:
CSK=0xDCBA;
printf("%d\n",CSK);
break;
case 4:
CSK=0xcab;
printf("%d\n",CSK);
break;
case 5:
CSK=0x0F;
printf("%d\n",CSK);
break;
case 6:
CSK=0770;
printf("%d\n",CSK);
break;
case 7:
CSK=0321;
printf("%d\n",CSK);
break;
case 8:
CSK=0333;
printf("%d\n",CSK);
break;
case 9:
CSK=0300;
printf("%d\n",CSK);
break;
case 10:
CSK=03232;
printf("%d\n",CSK);
break;
case 11:
CSK=145;
printf("%d\n",CSK);
break;
case 12:
CSK=185;
printf("%d\n",CSK);
break;
case 13:
CSK=225;
printf("%d\n",CSK);
break;
case 14:
CSK=355;
printf("%c\n",CSK);
break;
case 15:
CSK=455;
printf("%d\n",CSK);
break;
case 16:
UCSK=0x12345;
printf("%d\n",UCSK);
break;
case 17:
UCSK=0xAC;
printf("%d\n",UCSK);
break;
case 18:
UCSK=0xCC;
printf("%d\n",UCSK);
break;
case 19:
UCSK=0x786;
printf("%d\n",UCSK);
break;
case 20:
UCSK=0xBBC;
printf("%d\n",UCSK);
break;
case 21:
UCSK=500;
printf("%d\n",UCSK);
break;
case 22:
UCSK=1010;
printf("%d\n",UCSK);
break;
case 23:
UCSK=1023;
printf("%d\n",UCSK);
break;
case 24:
UCSK=-100;
printf("%d\n",UCSK);
break;
case 25:
UCSK=-'A';
printf("%d\n",UCSK);
break;
}
}
}
----------------------------------------------------------------------------------------------------------------------------
#include<stdio.h>
void main()
{
int question;
char ch;
printf("---- Solutions of Number Systems ----\n");
while(1)
{
printf("Enter question number : ");
scanf("%d",&question);
switch(question)
{
case 1:
ch = 'A';
printf("%d\n",ch);
break;
case 2:
ch = 'd';
printf("%d\n",ch);
break;
case 3:
ch = '3';
printf("%d\n",ch);
break;
case 4:
ch = 50;
printf("%c\n",ch);
break;
case 5:
ch = 99;
printf("%c\n",ch);
break;
case 6:
ch = 85;
printf("%d\n",ch);
break;
case 7:
ch = 125;
printf("%d\n",ch);
break;
case 8:
ch = 0x12;
printf("%d\n",ch);
break;
case 9:
ch = 0x48;
printf("%d\n",ch);
break;
case 10:
ch = 0x2F;
printf("%d\n",ch);
break;
case 11:
ch = 11;
printf("%d\n",ch);
break;
case 12:
ch = 0x11;
printf("%d\n",ch);
break;
case 13:
ch = 011;
printf("%d\n",ch);
break;
case 14:
ch = 0111;
printf("%d\n",ch);
break;
case 15:
ch = 055;
printf("%d\n",ch);
break;
case 16:
printf("Error");
// ch = 029;// Invalid
printf("%d\n",ch);
break;
case 17:
ch = 0x29;
printf("%d\n",ch);
break;
case 18:
ch = 200;
printf("%d\n",ch);
break;
case 19:
ch = 300;
printf("%d\n",ch);
break;
case 20:
ch = 0x123;
printf("%d\n",ch);
break;
case 21:
ch = 0x101;
printf("%d\n",ch);
break;
case 22:
ch = 0101;
printf("%c\n",ch);
break;
case 23:
ch = 'a';
printf("%o\n",ch);
break;
case 24:
ch = 'e';
printf("%x\n",ch);
break;
case 25:
ch = '0';
printf("%x\n",ch);
break;
case 26:
printf("Error");
//ch = A;
printf("%c\n",ch);
break;
case 27:
ch = 0xA;
printf("%d\n",ch);
break;
case 28:
ch = 0x1070;
printf("%d\n",ch);
break;
case 29:
ch = 141;
printf("%d\n",ch);
break;
case 30:
ch = 241;
printf("%d\n",ch);
break;
case 31:
ch = 291;
printf("%d\n",ch);
break;
}
}
}
Comments
Post a Comment