lab programs

No Comments

Java program to print Small Integer, Largest Integer

1 2 3 4 5 6 7 8 9 10 11 12 13 14 /* Write a program that will read a float type value from the keyboard and print the following output. ->Small Integer not less than the number. ->Given Number. ->Largest Integer not greater than the number. */ class ValueFormat{ public static void […]

2 Comments

Java program to find Minimum of 2 nos. using conditional operator

1 2 3 4 5 6 7 8 9 10 class Minof2{ public static void main(String args[]){ //taking value as command line argument. //Converting String format to Integer value int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); int result = (i<j)?i:j; System.out.println(result+" is a minimum value"); } }

No Comments

Java program to find Maximum of 2 nos

1 2 3 4 5 6 7 8 9 10 11 12 class Maxof2{ public static void main(String args[]){ //taking value as command line argument. //Converting String format to Integer value int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); if(i > j) System.out.println(i+" is greater than "+j); else System.out.println(j+" is greater than "+i); } }

4 Comments

C program for Macro Processor

C program for Macro Processor #include<stdio.h> #include<conio.h> #define getx1y1 printf("Enter the order of Ist Matrix:"); scanf("%d%d",&x1,&y1);   #define getx2y2 printf("Enter the order of IIst Matrix:"); scanf("%d%d",&x2,&y2);   #define inputa printf("Enter the value of a:"); for(i=0;i<x1;i++) for(j=0;j<y1;j++) scanf("%d",&a[i][j]);   #define inputb printf("Enter the value of b:"); for(i=0;i<x2;i++) for(j=0;j<y2;j++) scanf("%d",&b[i][j]);   #define addab for(i=0;i<x1;i++) { for(j=0;j<y1;j++) { […]