Sunday, 12 March 2023
5. Write an interface called numbers, with a method in Process(int x, int y). Write a class called Sum, in which the method Process finds the sum of two numbers and returns an int value. Write another class called Average, in which the Process method finds the average of the two numbers and returns an int.
4. Write program to create an array of company name and another array of price quoted by the company. Fetch the company name who has quoted the lowest amount.
3. Write a program to find sum of two matrices of 3 x3.
2. Write a program to create an array to store 5 integer values. Also initialize the array with 5 numbers and display the array Elements in reverse order
1. Write a program to sort the elements of one dimensional array. Read value of array elements through command line argument.
10. Write a java program to display powers of 2 i.e. 2,4,8,16 etc up to 1024 using bitwise operators.
9. A bank gives 6.5% per annum interest on deposits made in that bank. Write a program to calculate the total amount that a person will receive after the end of 5 years for a deposit of Rs.5000 for compound interest. Create necessary methods and constructors too.
8. A shop during festival season offers a discount 10% for purchase made up to Rs.1,000, 12% for purchase value of Rs.1,000 or more up to Rs 1,500 and 15% for purchase value of Rs.1,500 or more. Write a program to implement the above scheme for a given sales and print out the sales and print out the sales value, discount and net amount payable by a customer. Create necessary methods and constructors
7. Create a complex number class. The class should have a constructor and methods to add, subtract and multiply two complex numbers and to return the real and imaginary parts.
6. Write a program to calculate the area of square and rectangle by overloading the area method.
5. Write a program to calculate the hypotenuse of right angled triangle when other sides of the triangle are given. (Hypotenuse = square root (x*x + Y *Y))
4. Write a java program to scan 3 integer values from the command line argument and display the maximum number using conditional operator.
3. A car accessories shop assigns code 1 to seat covers, 2 to steering wheel covers , 3 to car lighting and 4 for air purifiers. All other items have code 5 or more. While selling the goods, a sales tax of 2% to seat covers ,3% to steering wheel covers, 4% to car lighting, 2.5% to air purifiers and 1.2% for all other items is charged. A list containing the product code and price is given for making a bill. Write a java program using switch statements to prepare a bill.
2. A motor cycle dealer sells two-wheelers to his customer on loan, which is to be repaid in 5 years. The dealer charges simple interest for the whole term on the day of giving the loan itself. The total amount is then divided by 60(months) and is collected as equated monthly instalment (EMI). Write a program to calculate the EMI for a loan of Rs. X, where X is given from command line argument. Print the EMI value in rupees.
1. Write a program to evaluate simple interest of a given principle, rate and time.
Saturday, 27 August 2022
Merge Sort in C Language
// merge sort...
#include<stdio.h>
#include<conio.h>
void main()
{
int no, i, j, l=0, mid, r, count=-1, temp, flag=0;
int arr[20], a[20], b[20];
clrscr();
printf("how many element you want to enter: ");
scanf("%d",&no);
r = no-1;
printf("\nenter element one by one: \n");
for(i=0; i<no; i++)
{
printf("enter %d element: ",i+1);
scanf("%d",&arr[i]);
}
mid = (l+r) / 2;
for(i=0; i<=mid; i++)
{
a[i] = arr[i];
count++;
}
for(i=0; i<mid; i++)
{
flag=0;
for(j=0; j<mid-i; j++)
{
if(a[j] > a[j+1])
{
flag=1;
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
if(flag==0)
{
break;
}
}
for(i=0; i<r-count; i++)
{
b[i] = arr[i+mid+1];
}
for(i=0; i<r-count-1; i++)
{
flag=0;
for(j=0; j<r-count-1-i; j++)
{
if(b[j] > b[j+1])
{
flag=1;
temp = b[j];
b[j] = b[j+1];
b[j+1] = temp;
}
}
if(flag==0)
{
break;
}
}
l=0; r=0; i=0;
while((l <= mid+1) && (r <= no-1))
{
if(b[r] < a[l])
{
if(r-1 != no-1)
{
arr[i] = b[r];
i++; r++;
}
else if((r-1 == no-1) && (l != mid))
{
arr[i] = a[l];
i++; l++;
}
}
else if(a[l] < b[r])
{
if(l-1 != mid)
{
arr[i] = a[l];
i++; l++;
}
else if((l-1 == mid) && (r-1 != no-1))
{
arr[i] = b[r];
i++; r++;
}
}
else
{
arr[i] = a[l];
i++; l++;
arr[i] = b[r];
i++; r++;
}
}
printf("\n\nsorted element:");
for(i=0; i<no; i++)
{
printf("%d ",arr[i]);
}
getch();
}
Bubble Sort in C Language
// Bubble sort...
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[20], no, i, j, temp, flag;
clrscr();
printf("how many element you want to enter: ");
scanf("%d",&no);
printf("\nenter element one by one:\n");
for(i=0; i<no; i++)
{
scanf("%d",&arr[i]);
}
for(i=0; i<no-1; i++)
{
flag=0;
for(j=0; j<no-1-i; j++)
{
if(arr[j] > arr[j+1])
{
flag=1;
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
if(flag==0)
{
break;
}
}
printf("\nsorted element: ");
for(i=0; i<no; i++)
{
printf("%d ",arr[i]);
}
getch();
}
Friday, 26 August 2022
Binary Search in C Language
#include<stdio.h>
#include<conio.h>
void main()
{
int no, arr[20], search, mid, l=0, r, i, j, temp;
clrscr();
printf("how many element you want to enter: ");
scanf("%d",&no);
printf("\nenter element one by one:\n");
for(i=0; i<no; i++)
{
printf("%d element: ",i+1);
scanf("%d",&arr[i]);
}
for(i=0; i<no-1; i++)
{
for(j=0; j<no-1; j++)
{
if(arr[j] > arr[j+1)
{
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
printf("\nyour element set in assending order: ");
for(i=0; i<no; i++)
{
printf("\n%d element: %d",i+1,arr[i]);
}
printf("\n\nsearch element: ");
scanf("%d",&search);
r=no-1;
while(l <= r)
{
mid = (l + r) / 2;
if(search == arr[mid])
{
printf("\n%d element at %d position",search,mid+1);
break;
}
else if(search < arr[mid])
{
r = mid-1;
}
else
{
l = mid+1;
}
}
if(l > r)
{
printf("\n%d element is not found",search);
}
getch();
}
python programs
1. sum of two number
-
class Program4 { public static void main ( String args []) { int a = Integer . parseInt (args[ 0 ]); int b...
-
1. Write a program to sort the elements of one dimensional array. Read value of array elements through command line argument. 2. Write a...
-
1. sum of two number