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

Datatype

data type in C programming language

Uploaded by

Akhil pandey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Datatype

data type in C programming language

Uploaded by

Akhil pandey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 2 (Class Work)

1. Write a program to demonstrate Boolean data type.


public class bool{
public sta c void main(String arg[]){
boolean b;
b= false;
System.out.println("b is : " +b);
b= true;
System.out.println("b is : " +b);
if(b)
System.out.println("This will executed");
b = false;
System.out.println("This is not executed");
System.out.println("10 > 9 is " +(10>9));
}
}

Output

2. Write a program to demonstrate char data type.


public class character{
public sta c void main(String arg[]){
char ch1, ch2;
ch1 = 88;
ch2 = 'Y';
System.out.println("ch1 : " +ch1);
System.out.println("ch2 : " +ch2);
}
}

Output
3. Write a program to demonstrate char data type.
public class character2{
public sta c void main(String arg[]){
char ch1;
ch1 = 'X';
System.out.println("ch1 : " +ch1);
ch1++;
System.out.println("ch2 a er increment : " +ch1);
}
}

Output

4. Write a program to demonstrate Dynamic Ini aliza on.


public class sqt{
public sta c void main(String arg[]){
double a = 3.0, b = 4.0;
if(a*b>10){
double c = Math.sqrt(a*a+b*b);
System.out.println("Value of c is " +c);
}
}
}

Output

5. Write a program to demonstrate Scope of a variable.


public class scope {
public sta c void main(String args[]) {
int x = 10;
if(x == 10) {
int y = 20;
System.out.println("x and y: " +x+" " +y);
x = y * 2;
}
int y = 100;
System.out.println("x and y: " + x + " " + y);
}
}
Output

6. Write a java program to understand String arg[].


import java.io.*;
public class third
{
public sta c void main(String args[]) {
System.out.println("hello: " );
System.out.println(args[0]);
}
}

Output

You might also like