source file name: LineSlope.C #include<math.h> void length(int x1, int y1, int x2, int y2) { int len; len=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); printf(" \n Length of Line=%d ",len); } int slope(int x1, int y1, int x2, int y2) { int m; m=(y2-y1)/(x2-x1); printf("\n Slope=%d",m); return m; …
Read more9)Write a JDBC Program that adds many records at a time using Prepared Statement.
source file name : PrepareLoop.java import java.sql.*; class PrepareLoop { public static void main(String as[]) { System.out.println("JDBC Program"); String names[]={"ram","kavita","soham","savita","sana"}; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDr…
Read more7) Write a program that finds Maximum from 2 numbers using user defined function.
source file name: MaxFun.C int max(int m, int n) // declaration and definition { int res; if(m>n) res=m; else res=n; return res; } void main() { int a,b; int result; clrscr(); printf("enter 2 numbers: "); scanf("%d%d",&a,&b); result= max(a,b); // calling function printf(" max…
Read more4) Write a C++ program that calculates sum of two class data members using Pointers to Members concept.
#include<iostream.h> #include<conio.h> class Ptr { int a,b; public: void set(int m, int n) { a=m; b=n; } friend int sum(Ptr p); }; int sum(Ptr ob) { int Ptr::* pa=&Ptr::a; int Ptr::* pb=&Ptr::b; Ptr *p=&ob; int s=ob.*pa+p->*pb; return s; } void main() { Ptr n; clrscr(); cout<<"\n…
Read more12) Write a program that displays Upper case and Lower case letters using While Loop.
source file name: UpperLower.C void main() { char ch; clrscr(); printf("\n Upper case letters\n "); ch=65; while(ch<=90) { printf(" %c ",ch); ch++; } printf("\n Lower case letters\n "); ch=97; while(ch<=122) { printf(" %c ",ch); ch++; } getch(); } output:
Read more5) Write a Java program that having Three sateFlower methods to display different Flower names using Method Overloading.
source file name: FlowerDemo.java class FlowerDemo { public void sateFlower() { System.out.println("Rose is beautiful flower"); } public void sateFlower(String s) { System.out.println(s+" is beautiful flower"); } public void sateFlower(String s, int n) { for(int i=1;i<=n;i++) { System.out.print…
Read more4) Write a Java program that to convert any given year into its Roman equivalents using Method overloading.
source file name: romandemo.java import java.io.*; class Roman { final char[] ch={'M','D','C','L','X','V','I'}; void roman(int cnt,char ch) { for(int n=1;n<=cnt;n++) System.out.print(ch+" "); } } class romandemo extends Roman { void roman(int n) { …
Read more