May 31, 2007

More than one class (JAVA Program)

class demo1
{
void add()
{
int a=10;
int b=20;
int c=a+b;
System.out.println(c);
}
};

class demo2
{
void sub()
{
int a=10;
int b=20;
int c=a-b;
System.out.println(c);
}
};

class demo
{
public static void main(String[] args)
{
demo1 d1;
d1 = new demo1();
demo2 d2;
d2 = new demo2();
d1.add();
d2.sub();
}
}
READ MORE - More than one class (JAVA Program)

May 28, 2007

JAVA program to demonstrate parameterized function

class demo
{
void add(int a,int b) // method definition
{
int c=a+b;
System.out.println(c);
}
};


class adddemo
{
public static void main(String[] args)
{
demo d1;
d1 =new demo();
d1.add(10,20); // calling of a function
}
}
READ MORE - JAVA program to demonstrate parameterized function

JAVA program to demonstrate function

class demo
{
void add() // method definition
{
int a,b,c;
a=10;
b=20;
c=a+b;
System.out.println(c);
}
};


class adddemo
{
public static void main(String[] args)
{
demo d1;
d1 =new demo();
d1.add(); // calling of a function
}
}
READ MORE - JAVA program to demonstrate function

JAVA program to add two integers

class adddemo
{
public static void main(String[] args)
{
int a,b,c;
a=10;
b=20;
c=a+b;
System.out.println(c);
}
}
READ MORE - JAVA program to add two integers

May 26, 2007

C++ program to demonstrate Structure

// This program will ask user to input Basic salary and program will
// calculate da 10%, hra 10%, pf 15%, fpf 20% and netamount according to
// this formula : net=bs +da+hra-pf-fpf
#include<iostream.h>
#include<conio.h>

struct student
{
int basicSalary;
float da,hra,pf,fpf,net;

void cal()
{
da = .1*basicSalary;
hra = .1*basicSalary;
pf = .15*basicSalary;
fpf = .2*basicSalary;
net= basicSalary*(1-.15);
}
};
main()
{
clrscr();

student s[5];

for(int i=0;i<=4;i++)
{

cout << "enter basic salary";
cin >> s[i].basicSalary;
s[i].cal();
cout<<"net "<<s[i].net<<endl;
}
getch();
}

READ MORE - C++ program to demonstrate Structure

May 25, 2007

Making Concentric Circles in C++ with dazzling effects:

Here is a C++ program that draw concentric circles with some special effects.

#include <iostream.h>
#include <graphics.h>
#include <conio.h>
#include <dos.h>
main()
{
int dv,mo;
dv = DETECT;
initgraph(&dv,&mo,"");
// logic to make outer circles
for(int j=40;j<=440;j+=80)
{
for(int i=40;i<=600;i+=80)
{
circle(i,j,40);
}
}

// logic to make concentric circles in each circles
for(j=40;j<=440;j+=80)
{
for(int i=40;i<=600;i+=80)
{
for(int k=0;k<=40;k++)
{
circle(i,j,k);
delay(10);
setcolor(k%16);
}
}
}

// logic to remove alternate drawn concentric circles.
setcolor(0);
int p=0;
for(j=440;j>=0;j-=80,p++)
if (p%2 == 0)
{for(int i=600;i>=0;i-=160)
for(int k=39;k>=0;k--)
{circle(i,j,k);delay(10);}}
else
{for(int i=40;i<600;i+=160)
for(int k=39;k>=0;k--)
{circle(i,j,k);delay(10);}}
getch();
closegraph();
}
READ MORE - Making Concentric Circles in C++ with dazzling effects:

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us