0% found this document useful (0 votes)
2 views6 pages

Basic Data Type

The document provides a series of programming exercises focused on number conversions between decimal, binary, octal, and hexadecimal systems, as well as various C programming code snippets demonstrating the use of different data types and their behavior with signed and unsigned values. It emphasizes solving problems manually without calculators or AI assistance, and checking answers using a terminal. The exercises cover a wide range of topics including type casting, arithmetic operations, and output formatting in C.

Uploaded by

udayer45
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Basic Data Type

The document provides a series of programming exercises focused on number conversions between decimal, binary, octal, and hexadecimal systems, as well as various C programming code snippets demonstrating the use of different data types and their behavior with signed and unsigned values. It emphasizes solving problems manually without calculators or AI assistance, and checking answers using a terminal. The exercises cover a wide range of topics including type casting, arithmetic operations, and output formatting in C.

Uploaded by

udayer45
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

NOTE:

Do not use Calculator while doing calculation(mainly while writting Binary).


Do not use Chatgpt.
First try to solve every question on paper and to check answer put question on
terminal. Check the answer,if it is correct move ahead and if it is not correct
check what your doing wrong by yourself.

Convert given number from decimal to binary, octal,hexadecimal


a] 1057
b] 2054
c] 1254

Convert given number from octal to binary,hexadecimal


a] 01056
b] 02225
c] 014755

Convert given number from hexadecimal to binary,octal


a] 0X2569
b] 0X25ABC
c] 0X25896DE

1]
void main()
{
char num=-369;
printf("%d\n",num);
}

2]
void main()
{
unsigned char num=-369;
printf("%d\n",num);
}

3]
void main()
{
char ch=01010;
printf("%d",ch);
printf("%o",ch);
printf("%X",ch);
}

4]
void main()
{
char ch=01710;
printf("%d",ch);
printf("%o",ch);
printf("%X",ch);
}

5]
void main()
{
unsigned char ch=01710;
printf("%d",ch);
printf("%o",ch);
printf("%X",ch);
}
6]
void main()
{
char ch=0xF0;
printf("%d",ch);
printf("%o",ch);
printf("%X",ch);
}

7]
void main()
{
unsigned char ch=0xF0;
printf("%d",ch);
printf("%o",ch);
printf("%X",ch);
}

8]
void main()
{
unsigned char ch= -0xF0;
printf("%d",ch);
printf("%o",ch);
printf("%X",ch);
}

9]
void main()
{
short int num=0xABCD;
printf("%x\n",num);
printf("%o\n",num);
}

10]
void main()
{
unsigned short int num=0xABCD;
printf("%x\n",num);
printf("%o\n",num);
}

11]
void main()
{
short int num=0x1BCD;
printf("%x",num);
printf("%o",num);
}

12]
void main()
{
unsigned short int num=0x1BCD;
printf("%x",num);
printf("%o",num);
}
13]
void main()
{
char ch =-500;
printf("%d\n",ch);
printf("%o\n",ch);
printf("%x\n",ch);
}

14]
void main()
{
unsigned char ch =-500;
printf("%d\n",ch);
printf("%o\n",ch);
printf("%x\n",ch);
}

15]
void main()
{
char ch=0xAB;
printf("%o\n",ch);
printf("%x\n",ch);
printf("%d\n",ch);
}

16]
void main()
{
unsigned char ch=0xAB;
printf("%o\n",ch);
printf("%x\n",ch);
printf("%d\n",ch);
}

17]
void main()
{

short int num=-300;


char ch;
ch=num;
printf("%hd\n",ch);
printf("%hx\n",ch);
printf("%X\n",ch);
printf("%o\n",ch);
}

18]
void main()
{

short int num=-300;


unsigned char ch;
ch=num;
printf("%hd\n",ch);
printf("%hx\n",ch);
printf("%X\n",ch);
printf("%o\n",ch);
}
19]
void main()
{
int num=025;
char ch=-15;
short int a=0x20;
ch=ch+a+num;
printf("%x\n",ch);
printf("%d\n",ch);
}

20]
void main()
{
unsigned int i=-5;
unsigned short int num=-5;
unsigned char ch=-5;
printf("%d\n",i);
printf("%d\n",num);
printf("%d\n",ch);
printf("%X\n",i);
printf("%X\n",num);
printf("%x\n",ch);
printf("%o\n",i);
printf("%o\n",num);
printf("%d\n",ch);
}

21]
void main()
{
unsigned char ch=562;
printf("%c\n",ch);
}

22]
void main()
{
unsigned char ch=-718;
printf("%c\n",ch);
}

23]
void main()
{
unsigned char ch=250;
ch=ch+0x25;
printf("%d\n",ch);
printf("%o\n",ch);
printf("%x\n",ch);
}

24]
void main()
{
unsigned short int num=0xFFCD;
printf("%d\n",num);
printf("%hd\n",num);
printf(“%o\n”,num);
printf(“%x\n”,num);
}
25]
int main()
{
short int _abc=-0xbc;
printf("%d\n",_abc);
printf("%o\n",_abc);
printf("%x\n",_abc);
}

26]
void main()
{
int a=-15;
char ch=a;
short int num=a;
printf("%d\n",ch);
printf("%o\n",ch);
printf("%x\n",ch);
printf("%hx\n",ch);
printf("%d\n",num);
printf("%o\n",num);
printf("%x\n",num);
printf("%hx\n",num);
}

27]
void main()
{
char ch=100;
ch=ch+284;
printf("%d\n",ch);
}

28]
void main()
{
unsigned char ch=100;
ch=ch+300;
printf("%d\n",ch);
}

29]
void main()
{
char ch=0xFFAB;
ch=-ch;
printf("%d\n",ch);
}

30]
void main()
{
char ch;
ch=0x82+0111+200;
printf("%d\n",ch);
}

31]
void main()
{
unsigned char ch;
ch=0x82+0111+200;
printf("%d\n",ch);
}
32]
void main()
{
char ch=-'a';
printf("%d\n",ch);
printf("%x\n",ch);
printf("%hx\n",ch);
printf("%ho\n",ch);
printf("%hd\n",ch);
}

33]
void main()
{
int num=-15;
unsigned short int num1=num;
short int num2=num;
printf("%x\n",num1);
printf("%x\n",num2);
}

You might also like