ThinkTronix
learning is fun...
Home
Home
E-Books
Robotics
Coding
C++
Tutorials
Robotics
Softwares
Social Profiles
Popular
Tags
Blog Archives
Popular Posts
Volume of a Cube, Cuboid & Cylinder using Function Overloading
Write a Program to find Volume of a Cube, Cuboid & Cylinder using Function Overloading. #include<iostream> using namespace std...
Robotics: Using Atmega16 Microcontroller - Introduction
What is a Microcontroller? A microcontroller is a single chip, self-contained computer which incorporates all the basic components of...
NI Multisim 11.0
NI Multisim (formerly MultiSIM ) is an electronic schematic capture and simulation program which is part of a suite of circuit desi...
Area using Default Arguments
Write a Program to find Area of a Square & Rectangle using Default Arguments. #include<iostream> using namespace std; int sqr(...
Swap using Call by Address.
Write a Program to enter two no.s and swap their values using Call by Address. #include<iostream> using namespace std; void swap(i...
Tags
C++ code
electronics
free download
free ebooks
mediafire
programming
software
video
Blog Archive
▼
2012
(24)
►
May
(1)
►
April
(3)
▼
February
(6)
Array of Objects
Area using Default Arguments
Banking System using Class
Friend Funtion
Nesting of Member Funtions
Sum of Time Objects
►
January
(14)
►
2011
(2)
►
December
(2)
Tuesday, February 28, 2012
Array of Objects
9:04 PM
array of objects
,
C++ code
,
programming
No comments
Write a Program to create a class employee having data members - employee no. & salary, and display data of 5 employees using Array of Objects.
#include<iostream> using namespace std; class employee { int emp_no; int sal; public: void input() { cout<<"Enter Employee Number: "; cin>>emp_no; cout<<"Enter salary: "; cin>>sal; } void display() { cout<<"Employee No.= "<<emp_no<<"\t\t"; cout<<"Salary= "<<sal<<endl; } }; int main() { employee emp[5]; int i; for(i=0;i<5;i++) emp[i].input(); for(i=0;i<5;i++) emp[i].display(); return 0; }
Read More
Area using Default Arguments
8:58 PM
C++ code
,
Default Argument
,
programming
No comments
Write a Program to find Area of a Square & Rectangle using Default Arguments.
#include<iostream> using namespace std; int sqr(int x=10); int rect(int y=10,int z=20); int main() { int ch; cout<<"1.Area of square\n2.Area of rectangle\nEnter choice: "; cin>>ch; switch(ch) { case 1:cout<<"Area= "<<sqr()<<endl; break; case 2:cout<<"Area= "<<rect()<<endl; break; default:cout<<"Wrong choice."; } return 0; } int sqr(int a) { return a*a; } int rect(int a,int b) { return a*b; }
Read More
Banking System using Class
8:47 PM
C++ code
,
programming
No comments
Write a menu driven Program to implement a Banking System using class having data members - Account no., Name & Balance, & member functions - Input, Display, Deposit & Withdraw.
#include<iostream> using namespace std; class bank { public: int ac_no; char name[20]; float balance; void input(); void display(bank); int deposit(); int withdraw(); }; void bank::input() { cout<<"Enter Account No.: "; cin>>ac_no; cout<<"Enter Name: "; cin>>name; cout<<"Enter Balance: "; cin>>balance; } void bank::display(bank a) { cout<<"Account No.: "<<a.ac_no<<endl; cout<<"Name: "<<a.name<<endl; cout<<"Balance= "<<a.balance<<endl; } int bank::deposit() { int dep; cout<<"Enter Deposit Amount: "; cin>>dep; return dep; } int bank::withdraw() { int wtdr; cout<<"Enter Withdraw Amount: "; cin>>wtdr; return wtdr; } int main() { int ch; bank a; while(1) { cout<<"\n\t1.Input\n\t2.Display\n\t3.Deposit\n\t4.Withdraw\n\t5.Exit\nEnter Choice:" ; cin>>ch; switch(ch) { case 1: a.input(); break; case 2: a.display(a); break; case 3: a.balance+=a.deposit(); cout<<"Current Balance= "<<a.balance<<endl; break; case 4: a.balance-=a.withdraw(); cout<<"Current Balance= "<<a.balance<<endl; break; case 5: return 0; default: cout<<"Wrong Choice."<<endl; } } }
Read More
Friend Funtion
8:24 PM
C++ code
,
friend function
,
programming
No comments
Write a Program to find sum of two complex no.s using Friend Function.
#include<iostream> using namespace std; class complex_add { public: int x,y; void input() { cout<<"Enter the real & imaginary part of complex no.:"; cin>>x>>y; } friend void show(complex_add,complex_add,complex_add); }; void show(complex_add p,complex_add q,complex_add r) { cout<<"First complex no.:= "<<p.x<<"+i"<<p.y<<endl; cout<<"Second complex no.:= "<<q.x<<"+i"<<q.y<<endl; cout<<"Sum of complex no.:= "<<r.x<<"+i"<<r.y<<endl; } int main() { complex_add a,b,s; a.input(); b.input(); s.x=a.x+b.x; s.y=a.y+b.y; show(a,b,s); return 0; }
Read More
Nesting of Member Funtions
8:20 PM
C++ code
,
member functions
,
nesting
,
programming
No comments
Write a Program to find the smallest no. in an array using Nesting of Member Functions.
#include<iostream> using namespace std; class num { int i,small,a[5]; public: int smallest(int b[5]) { small=b[0]; for(i=0;i<5;i++) if(b[i]<small)small=b[i]; return small; } void input() { cout<<"Enter the array elements :"; for(i=0;i<5;i++) cin>>a[i]; } void display() { cout<<"The smallest no.= "<<small<<endl; } void call() { input(); smallest(a); display(); } }; int main() { num small; small.call(); return 0; }
Read More
Sum of Time Objects
8:13 PM
C++ code
,
class
,
member functions
,
objects
,
programming
No comments
Write a Program to Create two time objects and find their sum using an object as a member function argument.
#include<iostream> using namespace std; class times { public: int hr,min; void input() { cout<<"Enter the time: "; cin>>hr>>min; } }; times add(times a,times b) { times sum; sum.hr=a.hr+b.hr; sum.min=a.min+b.min; return sum; } int main() { int hr_sum=0,min_sum=0; times t1,t2,sum; t1.input(); t2.input(); sum=add(t1,t2); if(sum.min>=60) { sum.hr+=1; sum.min-=60; } cout<<"Sum of Time = "<<sum.hr<<" : "<<sum.min<<endl; return 0; }
Read More
Newer Posts
Older Posts
Home