THERE ARE 2 PROJECTS OF C++
1ST Bookshop management system you can use it with your system adjust bcz in this
I used the file handling ;
2nd is that the CALCULATOR very interesting calculator :
1st
:
//1st BOOKSHOP MENEGEMENT SYSTEM :
#include<iostream>
#incluyde<fstream>
#include<stdio.h>
#include<stdlib.h>
using namespace std ;
//Book shopclass
class bookshope{
public:
void control_panel();
void add_book();
void show_book();
void check_book();
void update_book();
void del_book();
};
//Fuynction to dispalyu the menu
void bookshop::control_panel()
{
system("cls");
cout<<"\n\n\n\t\t\t\tCONTROL PANEL";
cout<<"\n1. ADD BOOK";
cout<<"\n2. DISPLAY BOOK";
cout<<"\n3. CHECK THE PARTICUYLAR BOOK";
cout<<"\n4. UP[DATE BOOK]";
cout<<"\n5. DELETE BOOK";
cout<<"\n6.EXIT";
}
// FUNCTION TO ADD A BOOK:
void bookshope add_book()
{
system("cls");
fstream file;
int no_copy;
string b_name;a_name;b_id;
cout<<"\n\n\t\tADD BOOKS";
cout<<"\n\nBook Id:";
cin>>b_id;
cout<<"\nbook name :";
cin>>b_name;
cout<<"\nauyther name :";
cin>>a_name;
cout<<"\nNo.Books :";
cin>>no_copy;
file.open("F:/hssn.text");
file<<" "<<b_id<<" "<<b_name<<" "<<a_name
<<" "<<no_copy<<"\n";
file.close();
}
//Function to display a book
void bookshop::show_book()
{
system("cls");
fstream file;
int no_copy;
string b_name;b_id;a_name;
cout<<"\n\\n\n\t\t\tALL BOOKS";
//OPen THe file in input mood
file.open("F:/hssn.text");
if(!file)
cout<<"\n\n\nFilE OPENING error !";
else {
cout <<"\n\nBOOK id\t\tbook "<<"\t\tAuthor\t\tNo.of books\n\n";
file>>b_id>>b_name;
file>>a_name >>no_copy;
//till end of file is reached
while(!file.eof())
{
cout<<" "<<b_id
<<"\t\t"<<b_name
<<"\t\t"<<a_name
<<"\t\t"<<no_copy
<<"\n\n";
file>>b_id>>b_name;
file>>a_name >>no_copy;
}
system("pause");
//close the file
file.close();
}
}
//function to check the book
void bookshop::check_book()
{
system("cls");
fstream file;
int no_copy,count=0;
string b_id,b_name<a_name,b_idd;
cout<<"\n\n\n\t\tcheck the
}
#include<iostream>
using namespace std;
int main()
{
int divisor,quotient,divined,reminder;
cout<<" \nEnter a divined number :"<<endl;
cin>>divined;
cout<<"\nEnter a divisor number :"<<endl;
cin>>divisor;
quotient= divined / divisor;
reminder= divined % divisor;
//
cout<<"\nthe quotient is :"<<quotient;
cout<<"\nthe reminder iss :"<<reminder;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int a=3;
int *b=&a; // address of operator
cout<<"the adrress of opertor is =:"<<&a;
cout<<"the adress of a is :"<<b<<endl;
// Derefrence operator
cout<<"the value at a adreess b is "<<*b<<endl;
return 0;
}
#include<iostream>
using namespace std ;
int main()
{
//x:
system("color 02");
cout<<"\nthe size of int :"<<sizeof(int)<<"\nbytes"<<endl;
cout<<"\nthe size of char :"<<sizeof(char)<<"\nbyte"<<endl;
cout<<"\nthe size of float :"<<sizeof(float)<<"\nbytes"<<endl;
cout<<"\nthe size of double :"<<sizeof(double)<<"\nbytes"<<endl;
//goto x;
return 0;
}
//pointers and pointers to pointers
#include<iostream>
using namespace std;
int main()
{
/*(address of) operator &
DEREFRENCE operator (value at) * --(*/
//address of operator :
int a=3;
a=57;
int *b=&a;
int **f=&b;
cout<<"the address of a is :"<<b<<endl;
cout<<"the adrress of a is :"<<&a<<endl;
//value at operator
cout<<"the value at a adress operator is :"<<*b<<endl;
cout<<"the value of pointer to pointer : "<<**f<<endl;//pointer to pointer
//pointer to pointer is define the address and value of pointers
int c=56;
int *d= &c;
int **e=&d;
cout<<"the adress of c is :"<<d<<endl;
cout<<"the adress of c is :"<<&c<<endl;
cout<<"THE VALUE OF OF IS :"<<*d<<endl;
cout<<"the value of c is :"<<**e<<endl;
return 0;
}
#include<iostream>
#include<iomanip>
using namespace std ;
int main()
{
system("color 02");
cout<<"\nthis is the exam of constant"<<endl;
const int s=54;
//a=2;this will be error if we un comment this becz cdue to constant of a there wil be no change :
int h=2;
cout<<"\nthe value of a is :"<<s;
cout<<"\nthe value iof b :"<<h;
/*now the example of manupulator :
we are discuss about two types off manupulator first is the endl :
2nd is that that we can define with the help of <iomanip>
header file with setw(4),setw(5) etc*/
cout<<"\nthis is the example of manupulator :"<<setw(7)<<endl;
int a=2,b=78,c=789;
cout<<"\nthese value with out setw(4) :"<<a<<endl;
cout<<"these value with out setw(4) :"<<b<<endl;
cout<<"these value with out setw(4) :"<<c<<endl;
cout<<"\nthese value with setw(4) :"<<setw(4)<<a<<endl;
cout<<"these value with setw(4) :"<<setw(4)<<b<<endl;
cout<<"these value with setw(4) :"<<setw(4)<<c<<endl;
cout<<"now we are taking about precedence and Assoocivity:"<<endl;
int d=15,e=5;float f;
f=(d/(e*3)+1)-((2*2)+4)-5; //we have two things precedence and associvity :
//used website en.cpp reference.com
cout<<f;
return 0;
}
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
system("color 20");
x:
cout<<" WELLCOME TO SCENTIFIC CALCULATOR "<<endl;
cout<<" ************* "<<endl;
cout<<endl;
cout<<" Press 1 For Addition Press 2 For Subtraction "<<endl;
cout<<" Press 3 For Multiplication Press 4 For Division "<<endl;
cout<<" Press 5 For Logrithm Press 6 For Cosine "<<endl;
cout<<" Press 7 For Sine Press 8 For Tangent "<<endl;
cout<<" Press 9 For Power Press 10 For Square Root "<<endl;
cout<<" Press 11 For Addition Of Matrix Press 12 For Subtraction Of Matrix "<<endl;
cout<<" Press 13 For Area Of Triangle Press 14 For Area and Cir of circle "<<endl;
cout<<" Press 15 For vf=vi+at Press 16 To Find Distance Covered "<<endl;
cout<<" Press 17 For S=v*t Press 18 TO Find Force "<<endl;
cout<<" Press 19 TO Find Density Press 20 TO Find Temp In Fahrenheit "<<endl;
cout<<" Press 21 TO Temp in Celsius"<<endl;
cout<<" Press 22 Exit "<<endl;
int choice;
cout<<" Now Enter Your Own Choice :";
cin>>choice;
system("cls");
switch(choice)
{
case 1:
cout<<endl;
cout<<" CALCULATING ADDITION FOR TWO NUMBERS "<<endl;
cout<<" ************** "<<endl;
int a,b,c;
cout<<"Enter 1st Number :";
cin>>a;
cout<<"Enter 2nd Number :";
cin>>b;
c=a+b;
cout<<"The sum is :"<<c;
cout<<endl;
cout<<" --------------------------------------- "<<endl;
goto x;
break;
case 2:
cout<<endl;
cout<<" CALCULATING DIFFERENCE OF TWO NUMBER "<<endl;
cout<<" ************** "<<endl;
int d,e,f;
cout<<"Enter 1st Number :";
cin>>d;
cout<<"Enter 2nd number :";
cin>>e;
f=d-e;
cout<<"Difference is :"<<f;
cout<<endl;
system("cls");
cout<<" --------------------------------------- "<<endl;
goto x;
break;
case 3:
cout<<endl;
cout<<" CALCILATING MULTILPLICATION FOR TWO NUMMBER "<<endl;
cout<<" **************** "<<endl;
int A,B,C;
cout<<"Enter 1st Number :";
cin>>A;
cout<<"Enter 2nd Number :";
cin>>B;
C=A*B;
cout<<"The Multiplication is :"<<C;
cout<<endl;
system("cls");
cout<<" ----------------------------------------------- "<<endl;
goto x;
break;
case 4:
cout<<endl;
cout<<" CALCULATING DIVISION FOR TWO NUMBER "<<endl;
cout<<" ************* "<<endl;
float D,E,F;
cout<<"Enter 1st Number :";
cin>>D;
cout<<"Enter 2nd Number :";
cin>>E;
F=D/E;
cout<<"The Division is :"<<F<<endl;
cout<<endl;
cout<<" -------------------------------------- "<<endl;
goto x;
break;
case 5:
cout<<" CALCULATING LOGRITHM "<<endl;
cout<<" ******* "<<endl;
float number,In;
cout<<"Enter a number :";
cin>>number;
In=log(number);
cout<<" Logrithm of "<<number<<" is :"<<In<<endl;
cout<<endl;
cout<<" ------------------------ "<<endl;
goto x;
break;
case 6:
cout<<" CALCULATING COSINE "<<endl;
cout<<" ****** "<<endl;
float n,n_cos;
cout<<"Enter a number :";
cin>>n;
n_cos=cos(n);
cout<<" cosine of "<<n<<" is :"<<n_cos<<endl;
cout<<endl;
cout<<" ----------------------- "<<endl;
goto x;
break;
case 7:
cout<<" CALCULATING SINE "<<endl;
cout<<" ****** " <<endl;
float num,num_sin;
cout<<"Enter a number :";
cin>>num;
num_sin=sin(num);
cout<<" sine of "<<num<<" is :"<<num_sin<<endl;
cout<<endl;
cout<<" ---------------------- "<<endl;
goto x;
break;
case 8:
cout<<" CALCULATING TANGENT "<<endl;
cout<<" ******x*** "<<endl;
float x,x_tan;
cout<<"Enter a number :";
cin>>x;
x_tan=tan(x);
cout<<" Tan of "<<x<<" is :"<<x_tan<<endl;
cout<<" ------------------------ "<<endl;
goto x;
break;
case 9:
cout<<" CALCULATING POWER "<<endl;
cout<<" ******* "<<endl;
double X,Y,power;
cout<<" Enter a number :";
cin>>X;
cout<<"Enter power of "<<X<<" : ";
cin>>Y;
power=pow(X,Y);
cout<<" Result of "<<X<<"^"<<Y<<" is :"<<power<<endl;
cout<<" ----------------------------- "<<endl;
goto x;
break;
case 10:
cout<<" CALCULATING SQUARE ROOT "<<endl;
cout<<" ********* "<<endl;
float z,sqroot;
cout<<"Enter a number :";
cin>>z;
sqroot=sqrt(z);
cout<<" The square root of "<<z<<" is :"<<sqroot<<endl;
cout<<" ------------------------------- "<<endl;
goto x;
break;
case 11:
cout<<" ADDITION OF MATRIX "<<endl;
cout<<" ******** "<<endl;
int p,q,r,s,P,Q,R,S,sum_1,sum_2,sum_3,sum_4;
cout<<"Enter the first number of first matrix :";
cin>>p;
cout<<"Enter the second number of first matrix :";
cin>>q;
cout<<"Enter the third number of first matrix :";
cin>>r;
cout<<"Enter the fourth number of first matrix :";
cin>>s;
cout<<"Enter the first number of second matrix :";
cin>>P;
cout<<"Enter the second number of second matrix :";
cin>>Q;
cout<<"Enter the third number of second matrix :";
cin>>R;
cout<<"Enter the fourth number of second matrix :";
cin>>S;
sum_1=p+P;
sum_2=q+Q;
sum_3=r+R;
sum_4=s+S;
cout<<endl;
cout<< " Sum of Martix "<<endl;
cout<<sum_1<<"\t"<<sum_2<<endl;
cout<<sum_3<<"\t"<<sum_4<<endl;
cout<<endl;
cout<<" ---------------------------------- "<<endl;
goto x;
break;
case 12:
cout<<" SUBTRACTION OF MATRIX "<<endl;
cout<<" ********* "<<endl;
int h,i1,j,k,H,I,J,K,sub_1,sub_2,sub_3,sub_4;
cout<<"Enter the first number of first matrix :";
cin>>h;
cout<<"Enter the second number of first matrix :";
cin>>i1;
cout<<"Enter the third number of first matrix :";
cin>>j;
cout<<"Enter the fourth number of first matrix :";
cin>>k;
cout<<"Enter the first number of second matrix :";
cin>>H;
cout<<"Enter the second number of second matrix:";
cin>>I;
cout<<"Enter the third number of second matrix :";
cin>>J;
cout<<"Enter the fourth number of second matrix:";
cin>>K;
sub_1=h-H;
sub_2=i1-I;
sub_3=j-J;
sub_4=k-K;
cout<<endl;
cout<<" The Difference is "<<endl;
cout<<sub_1<<"\t"<<sub_2<<endl;
cout<<sub_3<<"\t"<<sub_4<<endl;
cout<<" ---------------------------------- "<<endl;
goto x;
break;
case 13:
cout<<" AREA OF TRIANGLE "<<endl;
cout<<" ******** "<<endl;
float area,base,height;
cout<<"Enter base :";
cin>>base;
cout<<"Enter height :";
cin>>height;
area=base*height*.5;
cout<<" Area of triangle is : "<<area<<endl;
cout<<" -------------------------- "<<endl;
goto x;
break;
case 14:
cout<<" AREA AND CIRCUMFERENCE OF CIRCLE "<<endl;
cout<<" ************* "<<endl;
float ar,cir,radius;
cout<<"Enter the radius :";
cin>>radius;
ar=radius*radius*3.14;
cout<<"The are is :"<<ar<<endl;
cir=radius*2*3.14;
cout<<"The circumference is :"<<cir<<endl;
cout<<" ------------------------------------------ "<<endl;
goto x;
break;
case 15:
cout<<" PROGRAM FOR vf=vi+at "<<endl;
cout<<" ******** "<<endl;
float vi,ac,t,vf;
cout<<"Enter initial velocity vi :";
cin>>vi;
cout<<"Enter acceleration a :";
cin>>ac;
cout<<"Enter time t :";
cin>>t;
vf=(vi+ac)*t;
cout<<"Final velocity vf is :"<<vf<<endl;
cout<<endl;
cout<<" --------------------------------- "<<endl;
goto x;
break;
case 16:
cout<<" CALCULATING DISTANCE COVERED BY A BODY "<<endl;
cout<<" ************** "<<endl;
float velocity,time,acceleration,Distance;
cout<<"Enter initial velocity :";
cin>>velocity;
cout<<"Enter time :";
cin>>time;
cout<<"Enter acceleration :";
cin>>acceleration;
cout<<endl;
Distance=velocity*time+acceleration*time*time*1/2;
cout<<"Distance covered is :"<<Distance<<endl;
cout<<endl;
cout<<" ------------------------------------------ "<<endl;
goto x;
break;
case 17:
cout<<" CALCULATING S=v*t "<<endl;
cout<<" ******** "<<endl;
float v1,t1,S1;
cout<<"Enter the velocity :";
cin>>v1;
cout<<"Enter the time :";
cin>>t1;
S1=v1*t1;
cout<<"Distance is :"<<S1<<endl;
cout<<endl;
cout<<" ---------------------------------- "<<endl;
goto x;
break;
case 18:
cout<<" CALCULATING FORCE "<<endl;
cout<<" ********* "<<endl;
float m,a1,f1;
cout<<"Enter mass :";
cin>>m;
cout<<"Enter acceleration :";
cin>>a1;
f1=m*a1;
cout<<"Force is :"<<f1<<endl;
cout<<endl;
cout<<" ----------------------------- "<<endl;
goto x;
break;
case 19:
cout<<" CALCULATING DENSITY "<<endl;
cout<<" ******** "<<endl;
float M,V,D1;
cout<<"Enter Mass :";
cin>>M;
cout<<"Enter Volume :";
cin>>V;
D1=M/V;
cout<<"Density is :"<<D1<<endl;
cout<<endl;
cout<<" ---------------------------- "<<endl;
goto x;
break;
case 20:
cout<<" CALCULATING TEMPERATURE IN FAHRENHEIT "<<endl;
cout<<" ************** "<<endl;
float Ce,Fe;
cout<<"Enter temperature in celsius :";
cin>>Ce;
Fe=Ce*9/5+32;
cout<<"Temperature in Fahrenheit is :"<<Fe<<endl;
cout<<endl;
cout<<" --------------------------------------------- "<<endl;
goto x;
break;
case 21:
cout<<" CALCULATING TEMPERATURE IN CELSIUS "<<endl;
cout<<" ************* "<<endl;
float Feh,Cel;
cout<<"Enter temperature in Fahrenheit : ";
cin>>Feh;
Cel=(Feh-32)*5/9;
cout<<"Temperature in Celsius is :"<<Cel<<endl;
cout<<endl;
cout<<" -------------------------------------- "<<endl;
goto x;
break;
case 22:
exit(0);
break;
default:
cout<<" Invalid choice "<<endl;
cout<<" ---------------------------------- "<<endl;
goto x;
}
system("pause");
}
// There are two types of header files:
// 1. System header files: It comes with the compiler
#include<iostream>
// 2. User defined header files: It is written by the programmer
// #include "this.h" //--> This will produce an error if this.h is no present in the current directory
using namespace std;
int main(){
int a=4, b=5;
cout<<"Operators in C++:"<<endl;
cout<<"Following are the types of operators in C++"<<endl;
// Arithmetic operators
cout<<"The value of a + b is "<<a+b<<endl;
cout<<"The value of a - b is "<<a-b<<endl;
cout<<"The value of a * b is "<<a*b<<endl;
cout<<"The value of a / b is "<<a/b<<endl;
cout<<"The value of a % b is "<<a%b<<endl;
cout<<"The value of a++ is "<<a++<<endl;
cout<<"The value of a-- is "<<a--<<endl;
cout<<"The value of ++a is "<<++a<<endl;
cout<<"The value of --a is "<<--a<<endl;
cout<<endl;
// Assignment Operators --> used to assign values to variables
// int a =3, b=9;
// char d='d';
// Comparison operators
cout<<"Following are the comparison operators in C++"<<endl;
cout<<"The value of a == b is "<<(a==b)<<endl;
cout<<"The value of a != b is "<<(a!=b)<<endl;
cout<<"The value of a >= b is "<<(a>=b)<<endl;
cout<<"The value of a <= b is "<<(a<=b)<<endl;
cout<<"The value of a > b is "<<(a>b)<<endl;
cout<<"The value of a < b is "<<(a<b)<<endl;
// Logical operators
cout<<"Following are the logical operators in C++"<<endl;
cout<<"The value of this logical and operator ((a==b) && (a<b)) is:"<<((a==b) && (a<b))<<endl;
cout<<"The value of this logical or operator ((a==b) || (a<b)) is:"<<((a==b) || (a<b))<<endl;
cout<<"The value of this logical not operator (!(a==b)) is:"<<(!(a==b))<<endl;
return 0;
}
#include<iostream>
#include<windows.h>
//#include<graphics>
#include<bits/stdc++.h>
using namespace std;
int main()
{
HANDLE h=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttrbute(h,FOREGROUND_RED|FOREGROUND_INTENSITY);
int i,j,n;
cout<<"Enter n";
cin>>n;
cout<<endl;
for(i=n/2;i<=n;i+=2)
{
for(j=1;j<=n-i;j+=2)
{
cout<<"";
}
for (j=1;j<=i; j++)
{
cout<<"* ";
}
for(j=1;j<=n-i;j++)
{
cout<<" ";
}
for(int j=1;j<=i;j++)
{
cout<<"*";
}
cout<<endl;
for(i=n;i>=1;i--)
{
for(j=i;j<n;j++)
{
cout<<"";
}
for(j=1;j<=(i*2)-1;j++)
{
cout<<"*";
}
cout<<endl;
}
}
}
#include<iostream>
using namespace std;
int main()
{
system("color 02");
x:
float sum=0,a,n;
cout<<"enter the value for avrage :"<<endl;
cin>>n;
for(int i=0;i<n;i++)
{
sum=sum+i;
} /*avrage of all 0 to 1000 num */
a=sum/1000;
cout<<"the avg of all values 0 to 1000 :"<<a<<endl;
goto x;
return 0;
}
ALSO HAVE SOME INCLUDE DIFFERENT PROGRAMS OF SOLUTIONS :
variables and typecasting
#include<iostream>
using namespace std;
int c=45;
int main()
{
int a,b,c;
cout<<"Enter a number :"<<endl;
cin>>a;
cout<<"Enter a number :"<<endl;
cin>>b;
c=a+b;
cout<<"the sum is :"<<c;
cout<<"\nthe global variables of value is :"<<::c;
return 0;
}
swap value third variables
#include<iostream>
using namespace std;
int main()
{
int a=2,b=5,c;
cout<<"these are the before swapping values :"<<endl;
c=a;
a=b;
b=c; /*the formula of swapping with using third is this
and the formula of swapping variables with out using 3rd is that
a=a+b;
b=a-b;
a=a-b;*/
cout<<"\nthe value of a is 2 now after swapping :"<<a;
cout<<"\nthe value of b is 5 now after swapping :"<<b;
return 0;
}
0 Comments
Post a Comment