0% found this document useful (0 votes)
8 views1 page

Assignment 4

The document contains a series of programming questions related to variable declaration and type compatibility in a programming language. It discusses operations involving byte, short, int, and long data types, and addresses potential errors when storing sums in incompatible variable types. The questions prompt the reader to explore data type limits and the need for type casting to avoid errors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Assignment 4

The document contains a series of programming questions related to variable declaration and type compatibility in a programming language. It discusses operations involving byte, short, int, and long data types, and addresses potential errors when storing sums in incompatible variable types. The questions prompt the reader to explore data type limits and the need for type casting to avoid errors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Q1 Declare a variable of type byte and assign a value 45 to it.

Declare
another variable of type short and assign a value 12345 to it.
Now add these two variables and print sum.
Q2 Now what happen if you try to store the above sum in a byte
variable? Is there any error? if yes, then explain why this error and fix
this error.
Q3. Declare a variable of type int and assign a value 4567L and explain
why are you getting this error?
Q4. Declare a variable of type int and assign 100 to it. Declare another
variable of type long and assign a value 200 to it. Now add these two
numbers and print sum.
Q5 What happens if you try to store the above sum in int variable. Is
there any error? If yes then explain why this error and fix the error.

You might also like