Saturday, September 12, 2009

Draw A Diamond With Astericks(*) - : for cs201


// Justin C. Miller

// 3-27-2001
// made on: Unix Lab g++ compiler
// Title : creating a diamond shape
// Description: simple diamond shape using * 's

#include
#include

int main()
{
int i , j ;
int maxWidth = 11 ; // max width of the diamond
// top half of diamond
for(i = 0 ; i < (maxWidth/2 + 1) ; i++)
{
for(j = i ; j < (maxWidth/2) ; j++)
// used to align, putting in spaces
cout << " " ;
for(j = 1 ; j <= (i*2 + 1) ; j++)
// puts in the actual astericks
cout << "*" ;
cout <<>
}

// bottom half of diamond
for(i = (maxWidth/2) ; i > 0 ; i--){
for(j = (maxWidth/2 + 1) ; j > i ; j--)
// used to align, putting in spaces
cout << " " ;
for(j = (i*2 - 1) ; j > 0 ; j--) // puts in the actual astericks
cout << "*" ;
cout <<>
}

cout <<>

// PUTTING THE 2 HALVES TOGETHER!!!
for(i = 0 ; i <>
if(i <= (maxWidth/2)){
for(j = i ; j < (maxWidth/2) ; j++)
// used to align, putting in spaces
cout << " " ;
for(j =
1 ; j <= (i*2 + 1) ; j++) // puts in the actual astericks
cout << "*" ;
cout <<>
}
else{
for(j = (maxWidth/2 + 1) ; j > (maxWidth-i) ; j--)
// used to align, putting in spaces
cout << " " ;
for(j = ((maxWidth-i)*2 - 1) ; j > 0 ; j--) // puts in the actual astericks
cout << "*" ;
cout <<>
}

}

return 0 ;
}



Thursday, September 3, 2009

Program to enter an integer and print its total

Program to enter an integer and print its total value based on the formula'
x - 1/3!x^3 + 1/5!x^5 - 1/7!x^7 + 1/9!x^9':-

#include
#include
#include
int main()
{
clrscr();
float factorial=1;
float num,tot,term,total;
int i,n=20,index,j=1;
cout << "Enter a single-digit integer : \n"; cin>>num;
tot=num;
total=num;
for(i=2,index=3;i<=n;i++,index+=2)
{
for(j=1,factorial=1;j<=index;j++)
factorial*=j;
tot=tot*pow((double)(-1),(double)(2*i-1))*num*num;
term=tot/factorial;
total+=term;
}
cout << "Total = " << total << endl;
getch();
return 0;
}

Monday, July 6, 2009

Hide Your harddrives

If you have sensitive or important data stored on a particular disk drive that you don’t want anyone to see, a great way to hide it is to remove the drive letter assigned to a particular mounted volume. With Windows XP, you can achieve this easily using nothing more than the Command Prompt. Here's how:

- Click Start -> Run (This brings up the Run dialog box)
-Type cmd and press Enter (This brings up the Windows Command Prompt)
- Type diskpart in the command prompt and press Enter (This launches the Diskpart utility within the Command Prompt window)
- Now type list volume (This displays a list of all mounted volumes on your computer and their associated drive letters)


- Using the above picture as reference, if, for example, you would like to hide drive E, type select volume 2
- Now type remove letter E (Note: This sometime requires a reboot)
Diskpart will now remove the drive letter. The drive will no longer be available via Windows Explorer or My Computer.
Don’t worry though, your data remains safe!Now, should you want to unhide the drive and make it accessible again, just repeat the above process.
But instead of typing remove letter E, type assign letter E

Merge Sort C++ Source Code

#include
#include

int main () {
ifstream f1, f2;
ofstream f3;
int i,j;

f1.open("n1");
f2.open("n2");
f3.open("n1n2");

f1 >> i;
f2 >> j;
while (f1 && f2) {
if (i <>> i;
}
}
else {
while (j <= i && f2 && f3) { f3 <<>> j;
}
}
}
while (f1) {
f3 <<>> i;
}
while (f2) {
f3 <<>> j;
}
return (0);
}