0% found this document useful (0 votes)
7 views

Lab Assignment 1

Uploaded by

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

Lab Assignment 1

Uploaded by

sambitt812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CSE 1001: Introduction to Computer Programming

Programming Assignment-1
(Elements of Programming)
Question-1:
Write a java program to display following messages.
Hello “ITERIAN”
Welcome to Siksha ‘O’ Anusandhan Family.
Welcome to “Introduction to Computer Laboratory”
Java is fun for All !!

Question-2:
Write a complete Java program that shows the pattern similar to the following.

Question-3:
Write a java program to print the following pattern using Hash (#).

##########################################
## ##
## ##
## ##
## ##
## ##
##########################################

Question-4:
Write a java program that will display your First, Middle and Last name in different lines
without using the method println( ).
Question-5:
Write a java program to greet someone. Your program stores person name and greeting
message into two variables, and displays their values on the screen.

E.g. Hey Rishi, Good Morning!

Question-6:
Write a java program to store your Bank account no, name and balance in three different
variables and display their value on the screen as given:

“My name is Amit Kumar bearing account number 123456


having balance 7654.98”

Question-7:
Write a java program to exchange the values of two variables of integer type X and Y using
third temporary variable Z

Question-8:
Write a java program to exchange the values of two variables of integer type X and Y without
using third temporary variable.

Question-9:
What do each of the following print?

a) System.out.println(5);
b) System.out.println((float)25/6);
c) System.out.println(5+'6');
d) System.out.println(5+7+'9');
e) System.out.println("92"+7+5);
f) System.out.println(2+"9");
Question-10:
Assume a string variable ruler1 contains “1” initially i.e. String ruler1=”1” Write a java
program to print the following output using string concatenation. (You can take extra string
variables)
1
1 2 1
1 2 1 3 1 2 1
1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
HOME ASSIGMENT
Question-1:
What do each of the following print?

a) System.out.println(2 + "bc");
b) System.out.println(2 + 3 + "bc");
c) System.out.println((2+3) + "bc");
d) System.out.println("bc" + (2+3));
e) System.out.println("bc" + 2 + 3);

Question-2:
What do each of the following print?

a) System.out.println('b');
b) System.out.println('b' + 'c');
c) System.out.println((char) ('a' + 4));

Question-3:
Suppose that a variable a is declared as int a = 2147483647 (or equivalently,
Integer.MAX_VALUE ). What do each of the following print?

a) System.out.println(a);
b) System.out.println(a+1);
c) System.out.println(2-a);
d) System.out.println(-2-a)
e) System.out.println(2*a);
f) System.out.println(4*a);

Question-4:
Suppose that a variable a is declared as double a = 3.14159. What do each of the following
print?

a) System.out.println(a);
b) System.out.println(a+1);
c) System.out.println(8/(int) a);
d) System.out.println(8/a);
e) System.out.println((int) (8/a));
Question-5:
Write a java program to exchange the value of 4 variables W,G,K,A such that the value of
W will move to A, A to K, K to G and finally G to W. Exchange using with and without
using extra variables

***********************

You might also like