Program to receive nucleotide character sequence of 1st strand and print the sequence of the other strand
___________________________________by:Satyam Singh
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
char ch;
cout<<"first strand:\n2nd strand:";
for(int i=0,j=2;ch!='\0';++j,++i)
{ gotoxy(12+j,1);
ch=getche();
if(ch=='A')
{ gotoxy(j+12,2); cout<<'T'; gotoxy (12+j),1);
}
else if(ch=='T')
{ gotoxy(j+12,2);
cout<<'A';
gotoxy(12+j,1);}
else if(ch=='C')
{ gotoxy(j+12,2);
cout<<'G';
gotoxy(12+j,2);}
else if(ch=='G')
{ gotoxy(j+12,2);
cout<<'C';
gotoxy(12+j,2);}
else break;}
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
char ch;
cout<<"first strand:\n2nd strand:";
for(int i=0,j=2;ch!='\0';++j,++i)
{ gotoxy(12+j,1);
ch=getche();
if(ch=='A')
{ gotoxy(j+12,2); cout<<'T'; gotoxy (12+j),1);
}
else if(ch=='T')
{ gotoxy(j+12,2);
cout<<'A';
gotoxy(12+j,1);}
else if(ch=='C')
{ gotoxy(j+12,2);
cout<<'G';
gotoxy(12+j,2);}
else if(ch=='G')
{ gotoxy(j+12,2);
cout<<'C';
gotoxy(12+j,2);}
else break;}
getch();
}
Program to split an array when limit is given by user
_________________________________by:Satyam singh
#include<iostream.h>
#include<conio.h>
void compare(int,int,int[]);//int[] used for array
void main()
{ clrscr();
int lim,size;
cout<<"\n Enter the limit: ";
cin>>lim;
cout<<"\n Enter required size of array: ";
cin>>size;
int *num= new int[size];//declaring an array & to give the size of array
for(int i=0;i<size;++i)
cin>>num[i];
compare(lim,size,num);
getch();
}
void compare(int b,int c,int a[])
{ int *sma=new int[c],*gre=new int[c];
int y=0,z=0;
for(int i=0;i<c;++i)
{ if(b>a[i])
{sma[y]=a[i];++y;}
else if(b<a[i])
{gre[z]=a[i];++z; }
}
cout<<"\n Smaller: ";
for(i=0;i<y;++i)
cout<<sma[i]<<"\n";
cout<<"\n Greater: ";
for(i=0;i<z;++i)
cout<<gre[i]<<"\n";
}
#include<conio.h>
void compare(int,int,int[]);//int[] used for array
void main()
{ clrscr();
int lim,size;
cout<<"\n Enter the limit: ";
cin>>lim;
cout<<"\n Enter required size of array: ";
cin>>size;
int *num= new int[size];//declaring an array & to give the size of array
for(int i=0;i<size;++i)
cin>>num[i];
compare(lim,size,num);
getch();
}
void compare(int b,int c,int a[])
{ int *sma=new int[c],*gre=new int[c];
int y=0,z=0;
for(int i=0;i<c;++i)
{ if(b>a[i])
{sma[y]=a[i];++y;}
else if(b<a[i])
{gre[z]=a[i];++z; }
}
cout<<"\n Smaller: ";
for(i=0;i<y;++i)
cout<<sma[i]<<"\n";
cout<<"\n Greater: ";
for(i=0;i<z;++i)
cout<<gre[i]<<"\n";
}
____________________________________________________________
Program to find the cube of the individual digits of a number.
____________________________________by:Kunal Kumar
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,cube,sum=0,rem;
cout<<"\nEnter the number: ";
cin>>a;
while(a>0)
{ rem=a%10;
cube=a*a*a;
sum+= cube;
a/=10;
}
cout<<"\nThe cube sum of individual digits is: "<<sum;
getch();
}
Program to do operations on complex numbers
________________________________________by:Satyam Singh
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{ int ch;float zr1,zi1,zr2,zi2,zra,zia;
do
{
clrscr();
cout<<"\n\t\t\t Operations on Complex numbers\n 1.Addition \n 2.Substraction\
\n 3.Multiplication \n 4.Division \n 5.Exit \n Enter Your Choice: ";
cin>>ch;
if(ch>4)
break;
cout<<"\n Enter the two numbers\n First Number=>\n 1.Real Part: ";
cin>>zr1;
cout<<"\n 2.Imaginary Part: ";
cin>>zi1;
cout<<"\n Second number=>\n 1.Real Part: ";
cin>>zr2;
cout<<"\n 2.Imaginary Part: ";
cin>>zi2;
switch(ch)
{ case 1:
zra=zr1+zr2;
zia=zi1+zi2;
if(zia>0)
cout<<"\n The sum is: "<<zra<<"+"<<zia<<"i";
else
cout<<"\n The sum is: "<<zra<<zia<<"i";
break;
case 2:
zra=zr1-zr2;
zia=zi1-zi2;
if(zia>0)
cout<<"\n The difference is: "<<zra<<"+"<<zia<<"i";
else
cout<<"\n The difference is: "<<zra<<zia<<"i";
break;
case 3:
zra=((zr1*zr2)-(zi1*zi2));
zia=((zr1*zi2)+(zi1*zr2));
if(zia>0)
cout<<"\n The product is: "<<zra<<"+"<<zia<<"i";
else
cout<<"\n The product is: "<<zra<<zia<<"i";
break;
case 4:
zra=((zr1*zr2)-(zi1*(-zi2)))/(pow(zr2,2)+pow(zi2,2));
zia=((zr1*(-zi2))+(zi1*zr2))/(pow(zr2,2)+pow(zi2,2));
if(zia>0)
cout<<"\n The division result is: "<<zra<<"+"<<zia<<"i";
else
cout<<"\n The division result is: "<<zra<<zia<<"i";
break;
}
getch();
}while(ch<5);
}
#include<conio.h>
#include<math.h>
void main()
{ int ch;float zr1,zi1,zr2,zi2,zra,zia;
do
{
clrscr();
cout<<"\n\t\t\t Operations on Complex numbers\n 1.Addition \n 2.Substraction\
\n 3.Multiplication \n 4.Division \n 5.Exit \n Enter Your Choice: ";
cin>>ch;
if(ch>4)
break;
cout<<"\n Enter the two numbers\n First Number=>\n 1.Real Part: ";
cin>>zr1;
cout<<"\n 2.Imaginary Part: ";
cin>>zi1;
cout<<"\n Second number=>\n 1.Real Part: ";
cin>>zr2;
cout<<"\n 2.Imaginary Part: ";
cin>>zi2;
switch(ch)
{ case 1:
zra=zr1+zr2;
zia=zi1+zi2;
if(zia>0)
cout<<"\n The sum is: "<<zra<<"+"<<zia<<"i";
else
cout<<"\n The sum is: "<<zra<<zia<<"i";
break;
case 2:
zra=zr1-zr2;
zia=zi1-zi2;
if(zia>0)
cout<<"\n The difference is: "<<zra<<"+"<<zia<<"i";
else
cout<<"\n The difference is: "<<zra<<zia<<"i";
break;
case 3:
zra=((zr1*zr2)-(zi1*zi2));
zia=((zr1*zi2)+(zi1*zr2));
if(zia>0)
cout<<"\n The product is: "<<zra<<"+"<<zia<<"i";
else
cout<<"\n The product is: "<<zra<<zia<<"i";
break;
case 4:
zra=((zr1*zr2)-(zi1*(-zi2)))/(pow(zr2,2)+pow(zi2,2));
zia=((zr1*(-zi2))+(zi1*zr2))/(pow(zr2,2)+pow(zi2,2));
if(zia>0)
cout<<"\n The division result is: "<<zra<<"+"<<zia<<"i";
else
cout<<"\n The division result is: "<<zra<<zia<<"i";
break;
}
getch();
}while(ch<5);
}
Program to find the length of a given string. ____________________________________by:Kunal Kumar
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i , char text[80];
cout<<"\nEnter the string(max=80) :";
gets(text);
for( i=0 ; text[i]!='0' ; i++ )
cout<<"\nThe length of the string is: " <<i ;
getch();
}
0 comments :