Thursday, 12 April 2012

Addition Program In C++

Addition Program In C++
this is simple addition program for given two value
Sample Output:

Code:


/* www.mycfiles.com - Addition Program In C++*/
#include<iostream.h>
#include<conio.h>
class Add{
private:
int a,b,c;
public:
void getdata(){
cout<<"Enter The Values For The Addition\n";
cin>>a>>b;
}
void show(){
cout<<"Addition = "<<c;


}
void add();
};
void Add::add(){    //Here The Scope Resolution Operator Is Used
c=a+b;             //In Simple Words When Any Method Is Defined Outside Of The Class
}                 //This Operator Should Be Used
void main(){
/* The Object For Class Add Is "a"
This Is The Syntax To Create Object
Class_Name Object_Name*/
clrscr();
Add a;
a.getdata();
a.add();
a.show();
getch();


}

Comment bellow for your Query and Feedback.

Basic Hello World Program In C++

Basic Hello World Program In C++
Sample Output:

Code:
/* www.mycfiles.com - Basic Hello World Program In C++ */
#include<iostream.h>
#include<conio.h>
class Hello{
public :
void show(){


cout<<"Hello World I Am In C++";


}


};
void main(){
Hello h;            // The Object For Class hello Is "h"
h.show();         //This Is The Syntax To Create Object
getch();            //Class_Name Object_Name
}

Comment bellow for your Query and Feedback

Object Oriented Programming With C++ - 2nd Edition

Object Oriented Programming With C++ by E. Balagurusamy 
This is Second Edition book.
Description: 
Written by the most well known face of India's IT literacy movement, This book is designed for the first course in Object Oriented Programming with C++ taken by undergraduate students in Computers and Information Technology. It explores C++ in the light of its Object Oriented nature and simplifies it for novice programmers.
Author: E. Balagurusamy
Edition: 2
International Publisher: Mcgraw Hill Higher Education
No of Pages: 452
File Size: 62 mb
Key Features:
Detailed coverage of Object Oriented Systems Development.
Model C++ Proficiency Test included to strengthen the concepts learnt in the book.
Two new projects added onto main text and two new as part of the OLC Pedagogy
Example based conceptual approach.
The Book by E.Balguruswamy is Damn Good & Fantastic To Be Learnt for learning C++.
Contents : - 
Inheritance
Polymorphism
Encapsulation
Data Abstraction
Pointers
About Author : E BALAGURUSAMY: Member,Union Public Commission,Dholpur House, Shahjahan Road,New Delhi
DOWNLOAD
Hope this book will help you to learn C++, comment bellow for your Query and Feedback.. :)

C++ Program to Count and Print Even Numbers and Sum of Odd Numbers

C++ Program to Count and Print Even Numbers and Sum of Odd Numbers..
Sample Output:
Code:

//Program to count and print the number of even numbers and sum of odd numbers.
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int limit;
void cal(int);         //prototype void
cout<<"Enter Limit"<<endl;
cin>>limit;
cal(limit);          //calling the function
getch();
return(0);
}
void cal(int x)              //function cal with argument having one variable
{
int ctr=0,sum=0;
for(int i=1;i<=x;i++)
{
if(i%2==0)
{
ctr=ctr+1;
}
else
{
sum=sum+i;
}
}
cout<<"Even numbers="<<ctr<<endl;
cout<<"Sum of odd numbers="<<sum;
}

Comment bellow for your Query and Feedback... :)

C++ Progtam to Interchange the Value of Four Variables

C++ Progtam to Interchange the Value of Four Variables.
Sample Output:




Code:

//Progtam to interchange the value of four variables x,y,z,w
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int x,y,z,w;
void intchange(int,int,int,int);      //prototype void
cout<<"Enter values for x,y,z,w"<<endl;
cin>>x>>y>>z>>w;
intchange(x,y,z,w);           //calling the function
getch();
return(0);
}
void intchange(int x,int y,int z,int w)  //function intchange with argument having four variable
{
int temp=x;
x=w;
w=z;
z=y;
y=temp;
cout<<"new x="<<x<<endl;
cout<<"new y="<<y<<endl;
cout<<"new z="<<z<<endl;
cout<<"new w="<<w;
}

Comment bellow for your query and feedback.. :)

C++ Program for Exchange of Value of Two Variables Without Temporary Variable

C++ Program for Exchange of Value of Two Variables Without Temporary Variable
Sample Output:

Code:
/*program for exchange of value of two variables without temp variable*/

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int no1,no2;
void ex(int,int);  //prototype void
cout<<"enter value for a="<<endl;
cin>>no1;
cout<<"enter value for b="<<endl;
cin>>no2;
ex(no1,no2);   //calling the function
getch();


}
void ex(int a,int b)  //function ex with argument having two variables
{
a=a+b;
b=a-b;
a=a-b;
cout<<"new a="<<a<<endl;;
cout<<"new b="<<b;
}

Comment bellow for your query and feedback.. :)

C++ Program to Convert Digits to its Equivalent Words

Here is another tricky code, where we can Convert Digits to its Equivalent Words.

The program work till 5 digits of number

Suppose the Input is: 12345

Then the Output will be:  OneTwoThreeFourFive


Code:


//C++ Program to Convert Digits to its Equivalent Words
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5],i,n;
clrscr();
cout<<"Enter the Value";
cin>>n;
for(i=4;i>=0;i--)
{
a[i]=n%10;
n=n/10;
}
for(i=0;i<5;i++)
{
if(a[i]!=0)
{
switch(a[i])
{
case 0:cout<<"Zero";
break;
case 1:cout<<"One";
break;
case 2:cout<<"Two";
break;
case 3:cout<<"Three";
break;
case 4:cout<<"Four";
break;
case 5:cout<<"Five";
break;
case 6:cout<<"Six";
break;
case 7:cout<<"Seven";
break;
case 8:cout<<"Eight";
break;
case 9:cout<<"Nine";
break;
}
}
}
getch();
}

Also Read:


C Program to Convert Digits to its Equivalent Words


Hope you liked my posts, give comments if you have any doubts.. :)