Tuesday, July 12, 2011

average.cp

#include


class gobi2

{
public:

int coa,c,asp,total,avg1;

void add();

void avg();
};

void main()
{
gobi2 g2;

clrscr();
g2.add();

g2.avg();

getch();

}
void gobi2::add()
{
cout<<"enter the value of coa\n";

cin>>coa;

cout<<"enter the value of c\n";

cin>>c;

cout<<"enter the value of asp\n";

cin>>asp;

total=coa+asp+c;

}

void gobi2::avg()

{
avg1=total/3;

cout<<"the avarage of 3 subjects are:"<output:

enter the value of coa


35


enter the value of c

78


enter the value of asp

87

the avarage of 3 subjects are:66



add.cpp

#include
#include

class gobi
{

public:
int a,b,c;
void add();
void display();
};
int main()
{
gobi g;
g.add();
g.display();
getch();
return 0;
}
void gobi::add()
{
clrscr();
cout<<"enter the value of a\n";
cin>>a;
cout<<"enter the value of b\n";
cin>>b;
c=a+b;
}
void gobi::display()
{
cout<<"the value of c"<< c;
}

output:

enter the value of a

2

enter the value of b

4

the value of c 6



Monday, July 11, 2011

variable size of

Variables of type char occupy 1 bytes

Variables of type short occupy 2 bytes

Variables of type int occupy 4 bytes

Variables of type long occupy 4 bytes

Variables of type float occupy 4 byte

Variables of type double occupy 8 bytes

Variables of type long double occupy 12 bytes

Variables of type long double provide 18 decimal digits precision.

variable size

Variables of type char store values from -128 to 127

Variables of type unsigned char store values from 0 to 255

Variables of type short store values from -32768 to 32767

Variables of type unsigned short store values from 0 to 65535

Variables of type int store values from -2147483648 to 21474836
47
Variables of type unsigned int store values from 0 to 4294967295

Variables of type long store values from -2147483648 to 2147483647

Variables of type unsigned long store values from 0 to 4294967295

Variables of type long long store values from -9223372036854775808 to 9223372036854775807

Variables of type unsigned long long store values from 0 to 18446744073709551615


The size of the smallest non-zero value of type float is 1.175e-38

The size of the largest value of type float is 3.403e+38

The size of the smallest non-zero value of type double is 2.225e-308

The size of the largest value of type double is 1.798e+308

The size of the smallest non-zero value of type long double is 3.362e-4932

The size of the largest value of type long double is 1.190e+4932


Variables of type float provide 6 decimal digits precision.

Variables of type double provide 15 decimal digits precision.

variable

it is used to store the values

Difference between void main() and int main()

Void main():

its doesnt return the value.

Int main():

its return value.if use int main function we need to give return 0.because its doesnt return the value...

Thursday, July 7, 2011

Swap programs:

swap program using 2 variables:

#include

#include

void main()

{

int a,b;

clrscr();

printf("enter the value for a");

scanf("%d",&a);

printf("enter the value for b");

scanf("%d",&b);

a=a+b;

b=a-b;

a=a-b;

printf("the swap values are %d\t%d\n",a,b);

getch();


}

Output:

enter the value for a4

enter the value for b2

the sorting values are 2 4