Translate

Wednesday, 24 October 2012

Program for Concatenation of two strings

#include<iostream.h>
#include<conio.h>
#include<string.h>
class string
   {
     char st[20];
     public:
void input()
    {
cout<<"\nEnter the string=";
cin.getline(st,20);
    }
     string operator+(string s)
   {
     string temp;
     strcpy(temp.st,st);
     strcat(temp.st,s.st);
     return temp;
   }
     void output()
   {

     cout<<"\nThe string is="<<st;
   }
   };
void main()
      {
string s1,s2,s3;
clrscr();
s1.input();
s2.input();
s3=s1+s2;
s3.output();
getch();
      }

Thursday, 11 October 2012



\\Program for finding the given number is even or odd

#include<iostream.h>
#include<conio.h>
void main()

    {

      clrscr();
      int n;
      cout<<"Enter the number=";
      cin>>n;
      if(n%2==0)
cout<<"\n\nGiven number is even";
      else
cout<<"\n\nGiven number is Odd";
      getch();
    }

Saturday, 6 October 2012

Welcome to C/C++

#include<iostream.h>
#include<conio.h>
void main()
   {
         clrscr();     // clear the output screen
         cout<<"welcome to C/C++";  // print on screen
         getch();                                   // ask for enter any character
   }

Sunday, 30 September 2012

Pointers:

  Pointers are Special Type of variables which are used  to store the Address of Another variable or memory location. Using a pointer variable we can access and modify the value of  a variable of which it consists the address. A pointer variable can hold the address of one memory location at a time.

      the data type of pointer variable and the variable of which it consist the address should be same.


Syntax:

       dataType *ptrVariable;


note: we can't perform Arithmetic operations on Addresses except Subtraction.

    For example:

      int a,b;
 =&a+&b;(Invalid)

Saturday, 31 December 2011

Program for draw a circle using Bresenham's Algorithm


# include<stdio.h>
# include<conio.h>
# include<graphics.h>
# include<math.h>

void main()
{
int gd=DETECT,gm;
int r,x,y,p,xc=320,yc=240;

initgraph(&gd,&gm,"C:\\TC\\BGI");
cleardevice();


printf("Enter the radius ");
scanf("%d",&r);


x=0;
y=r;

p=3-(2*r);

for(x=0;x<=y;x++)
{
if (p<0)
{
y=y;
p=(p+(4*x)+6);
}
else
{
y=y-1;

p=p+((4*(x-y)+10));
}

putpixel(xc+x,yc-y,15);
putpixel(xc-x,yc-y,15);
putpixel(xc+x,yc+y,15);
putpixel(xc-x,yc+y,15);
putpixel(xc+y,yc-x,15);
putpixel(xc-y,yc-x,15);
putpixel(xc+y,yc+x,15);
putpixel(xc-y,yc+x,15);

}
getch();
closegraph();
}