0% found this document useful (0 votes)
46 views

Programming Tutorial (With Pictures)

This document includes programs written using C++. It provides you with the code that you need to get started and also includes the screen shots of the running programs

Uploaded by

Talha Noman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Programming Tutorial (With Pictures)

This document includes programs written using C++. It provides you with the code that you need to get started and also includes the screen shots of the running programs

Uploaded by

Talha Noman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PROGRAM#01

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a,b,x,y;
a=b=x=y=0;
a++;
b=a;
++x;
y=x;
cout<<"a="<<a<<endl<<"b="<<b<<endl;
cout<<"x="<<x<<endl<<"y="<<y<<endl;
return 0;

PROGRAM#02

#include<stdafx.h>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a,b,x,y;
a=b=x=y=0;
b=a++;
y=++x;
cout<<"a="<<a<<endl<<"b="<<b<<endl;
cout<<"x="<<x<<endl<<"y="<<y<<endl;
return 0;

PROGRAM#03

#include <stdafx.h>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a,b,x,y;
a=b=x=y=0;
a--;
b=a;
--x;
y=x;
cout<<"a="<<a<<endl<<"b="<<b<<endl;
cout<<"x="<<x<<endl<<"y="<<y<<endl;
return 0;}
PROGRAM#04

(point.h)
#pragma once
class point
{
private:
double xcoord,ycoord,c;
public:
point();
point(double a,double b);
};

(point.cpp)
#include "stdafx.h"
#include "point.h"
#include<iostream>
#include <cmath>
using namespace std;
point::point()
{
cout<<"Constructing point objects"<<endl;
cout<<"Initializing to zero"<<endl;
}
point::point(double a,double b)
{
cout<<"Constructing sum"<<endl;
xcoord=a;
ycoord=b;
c=a+b;
cout<<"Sum is"<<c<<endl;
}

(Main program)

#include "stdafx.h"
#include <iostream>
#include "point.h"
#include <cmath>
using namespace std;
int main()
{
cout<<"In main function(Constructor)#1"<<endl;
point p1;
cout<<"In main function(Constructor)#2"<<endl;
point p2(1.5,-4.7);
cout<<"In main function(Constructor)#3"<<endl;
const point ORIGIN(0.0,0.0);

return 0;
}
(PROGRAM#05)

(point.h)
#pragma once
class point
{
private:
int xcoord,ycoord,c;
public:
point();
point(int a, int b);
};

(point.cpp)
#include "stdafx.h"
#include "point.h"
#include<iostream>
#include <cmath>
using namespace std;
point::point()
{
cout<<"Constructing point objects"<<endl;
cout<<"Initializing to zero"<<endl;
}
point::point(int a,int b)
{
cout<<"Constructing remainder"<<endl;
xcoord=a;
ycoord=b;
c=b%a;
cout<<"Remainder is"<<c<<endl;
}

(Main program)

#include "stdafx.h"
#include <iostream>
#include "point.h"
#include <cmath>
using namespace std;
int main()
{
cout<<"In main function(Constructor)#1"<<endl;
point p1;
cout<<"In main function(Constructor)#2"<<endl;
point p2(27,6);
return 0;
}
PROGRAM#06

(point.h)
#pragma once
class point
{
private:
double xcoord,ycoord,c;
public:
point();
point(int a, int b);
};

(point.cpp)
#include "stdafx.h"
#include "point.h"
#include<iostream>
#include <cmath>
using namespace std;
point::point()
{
cout<<"Constructing point objects"<<endl;
cout<<"Initializing to zero"<<endl;
}
point::point(int a,int b)
{
cout<<"Constructing remainder"<<endl;
xcoord=a;
ycoord=b;
c=b/(double)a;
cout<<"Remainder is"<<c<<endl;
}

(Main program)

#include "stdafx.h"
#include <iostream>
#include "point.h"
#include <cmath>
using namespace std;
int main()
{
cout<<"In main function(Constructor)#1"<<endl;
point p1;
cout<<"In main function(Constructor)#2"<<endl;
point p2(27,6);
return 0;
}
PROGRAM#07

(point.h)
#pragma once
class point
{
private:
double ycoord,xcoord;
int a;
public:
point();
point(double c, double b);
};

(point.cpp)
#include "stdafx.h"
#include "point.h"
#include<iostream>
#include <cmath>
using namespace std;
point::point()
{
cout<<"Constructing point objects"<<endl;
cout<<"Initializing to zero"<<endl;
}
point::point(double c,double b)
{
cout<<"Constructing remainder"<<endl;
xcoord=c;
ycoord=b;
a=b/c;
cout<<"Remainder is"<<a<<endl;
}

(Main program)

#include "stdafx.h"
#include <iostream>
#include "point.h"
#include <cmath>
using namespace std;
int main()
{
cout<<"In main function(Constructor)#1"<<endl;
point p1;
cout<<"In main function(Constructor)#2"<<endl;
point p2(6,18.6);
return 0;
}
PROGRAM#08

(point.h)
#pragma once
class point
{
private:
double a,xcoord;
int ycoord;
public:
point();
point(double c, int b);
};

(point.cpp)
#include "stdafx.h"
#include "point.h"
#include<iostream>
#include <cmath>
using namespace std;
point::point()
{
cout<<"Constructing point objects"<<endl;
cout<<"Initializing to zero"<<endl;
}
point::point(double c, int b)
{
cout<<"Constructing OUTPUT"<<endl;
xcoord=c;
ycoord=b;
a=(int)c/b;
cout<<"OUTPUT___"<<a<<endl;
}

(Main program)
#include "stdafx.h"
#include <iostream>
#include "point.h"
#include <cmath>
using namespace std;
int main()
{
cout<<"In main function(Constructor)#1"<<endl;
point p1;
cout<<"In main function(Constructor)#2"<<endl;
point p2(18.6,6);
return 0;
}

You might also like