Book Entry Using structure Variable in C++ Programming
#include
#include
struct books
{
char
name[20],author[20];
}a[50];
int main()
{
int i,n;
cout<<"No Of Books[less than 50]:";
cin>>n;
cout<<"Enter the book
details\n";
cout<<"----------------------\n";
for(i=0;i
{
cout<<"Details of Book No
"<
cout<<"Book Name :";
cin>>a[i].name;
cout<<"Book Author :";
cin>>a[i].author;
cout<<"----------------------\n";
}
cout<<"============================================\n";
cout<<" S.No\t| Book Name\t|author\n";
cout<<"=============================================";
for(i=0;i
{
cout<<"\n
"<
}
cout<<"\n============================================";
return
0;
}
Output
No Of Books[less than 50]:2
Enter the book details
----------------------
Details of Book No 1
Book Name :Programming
Book Author :Dromy
Details of Book No 2
Book Name :C
Book Author :Byron
====================================================
S.No | Book Name |author
====================================================
1 |Programming | Dromy
2 |C | Byron
====================================================
C++ Binary Operator Overloading Using C++ Programming
#include
#include
using namespace std;
class overloading
{
int value;
public:
void
setValue(int temp)
{
value = temp;
}
overloading
operator+(overloading ob)
{
overloading t;
t.value=value+ob.value;
return(t);
}
void display()
{
cout<
}
};
int main()
{
overloading obj1,obj2,result;
int a,b;
cout<<"Enter
the value of Complex Numbers a,b:";
cin>>a>>b;
obj1.setValue(a);
obj2.setValue(b);
result =
obj1+obj2;
cout<<"Input
Values:\n";
obj1.display();
obj2.display();
cout<<"Result:";
result.display();
getch();
return 0;
}
Output
Enter the value of
Complex Numbers a,b:10
5
Input Values:
10
5
Result:15
Program for Function In C++
#include
#include
using namespace std;
void printmessage ()
{
cout <<
"Im Function In C++";
}
int main()
{
printmessage ();
getch();
return 0;
}
Output
Im Function in C++
Function Find Smallest Number in C++
#include
#include
using namespace std;
int compare( int a, int b )
{
return (a+4 < b)? a : b;
}
int main()
{
cout<<"\nSmallest
Number :"<
cout<<"\nSmallest
Number :"<
cout<<"\nSmallest
Number :"<
getch();
return 0;
}
Output
Smallest Number :1
Smallest Number :10
Smallest Number :8
No comments:
Post a Comment