//* CHAP # 2 Q # 24 *//
//* Find whether an intger is even or odd *//
#include <iostream.h>
void main ()
{
int a;
cout <<"Enter an integer";
cin>>a;
cout <<endl<<endl<< endl;
if (a%2==0)
cout <<"The integer is even ";
else
cout <<"The integer is odd ";
}
//* CHAP # 2 Q # 26 *//
//* PRINT THE specified patterrn according to the no of stars & lines by the user*
#include <iostream.h >
void main ()
{
int n;
cout <<"Enter the no Of stars";
cin>>n;
for(int i=0 ; i<n; i++ )
{
if(i%2==0)
{ for(int j=0; j<n ;j++)
{ cout <<"*"; }
cout<<endl;
}
else
{ cout<<" ";
for(int k=0 ; k<n ;k++)
{ cout <<"*";}
cout<<endl;
}
}
}
//* CHAP # 2 Q # 18 *//
//* Enter two integers and show which one is greater*//
#include <iostream.h>
void main ()
{ int a,b;
cout <<"Enter two integers\n";
cin>>a>>b;
if(a>b)
cout <<a<<"greater than"<<b;
else
cout <<b<<"greater than"<<a;
}
Chap # 4, Q # 13
#include <iostream.h>
void main()
{
float m,tmpg,mpg,g;
cout <<"Enter miles driven";
cin >>m;
cout <<"Enter gallons";
cin>>g;
mpg=(m/g);
tmpg=mpg;
cout<<"MPG this tank full="<<mpg<<endl;
cout <<"enter miles driven(-1 to quit)";
cin>>m;
while (m!=-1)
{
cout <<"Enter no of gallons\n";
cin>>g;
mpg=( m/g);
tmpg=(tmpg+mpg)/2;
cout<<"MPG this tank full="<<mpg<<endl;
cout <<"Total MPG="<<tmpg<<endl;
cout <<"Enter miles driven(-1 to quit) ";
cin >>m;
}
}
Chap # 4, Q # 15
//* Enter gross sales of a sales man and calculare his weekly sallery as company pays $200 *//
//* weekly & 9% of the gross sales ,we are to use a for loop and prog ends by entering *//
// * -1 as gross sales //
#include <iostream.h>
void main ()
{ int gs;float s;
cout <<"Enter the gross sales of an employee in dollars(-1 to quit)\n\n\n";
cin>>gs;
while( gs!=-1)
{
s=200+(0.09*gs);
cout<<"Weekly salary of the employee is"<<s<<endl<<endl;
cout <<"Enter the gross sales of an employee in dollars(-1 to quit)\n\n\n\n";
cin>>gs;
}
cout <<" (:(:(:(:(: GOOD BYE :):):):):):) ";
}
//* Find whether an intger is even or odd *//
#include <iostream.h>
void main ()
{
int a;
cout <<"Enter an integer";
cin>>a;
cout <<endl<<endl<< endl;
if (a%2==0)
cout <<"The integer is even ";
else
cout <<"The integer is odd ";
}
//* CHAP # 2 Q # 26 *//
//* PRINT THE specified patterrn according to the no of stars & lines by the user*
#include <iostream.h >
void main ()
{
int n;
cout <<"Enter the no Of stars";
cin>>n;
for(int i=0 ; i<n; i++ )
{
if(i%2==0)
{ for(int j=0; j<n ;j++)
{ cout <<"*"; }
cout<<endl;
}
else
{ cout<<" ";
for(int k=0 ; k<n ;k++)
{ cout <<"*";}
cout<<endl;
}
}
}
//* CHAP # 2 Q # 18 *//
//* Enter two integers and show which one is greater*//
#include <iostream.h>
void main ()
{ int a,b;
cout <<"Enter two integers\n";
cin>>a>>b;
if(a>b)
cout <<a<<"greater than"<<b;
else
cout <<b<<"greater than"<<a;
}
Chap # 4, Q # 13
#include <iostream.h>
void main()
{
float m,tmpg,mpg,g;
cout <<"Enter miles driven";
cin >>m;
cout <<"Enter gallons";
cin>>g;
mpg=(m/g);
tmpg=mpg;
cout<<"MPG this tank full="<<mpg<<endl;
cout <<"enter miles driven(-1 to quit)";
cin>>m;
while (m!=-1)
{
cout <<"Enter no of gallons\n";
cin>>g;
mpg=( m/g);
tmpg=(tmpg+mpg)/2;
cout<<"MPG this tank full="<<mpg<<endl;
cout <<"Total MPG="<<tmpg<<endl;
cout <<"Enter miles driven(-1 to quit) ";
cin >>m;
}
}
Chap # 4, Q # 15
//* Enter gross sales of a sales man and calculare his weekly sallery as company pays $200 *//
//* weekly & 9% of the gross sales ,we are to use a for loop and prog ends by entering *//
// * -1 as gross sales //
#include <iostream.h>
void main ()
{ int gs;float s;
cout <<"Enter the gross sales of an employee in dollars(-1 to quit)\n\n\n";
cin>>gs;
while( gs!=-1)
{
s=200+(0.09*gs);
cout<<"Weekly salary of the employee is"<<s<<endl<<endl;
cout <<"Enter the gross sales of an employee in dollars(-1 to quit)\n\n\n\n";
cin>>gs;
}
cout <<" (:(:(:(:(: GOOD BYE :):):):):):) ";
}