Title: Print statement without using semicolan(;)
Program:
Easy programming and better way to learn the programming . if you like the scorce code do like like share and subscribe the chennel.
Title: Print statement without using semicolan(;)
Program:
#include<iostream>
using namespace std;
int main()
{
int i;
char ch[30];
cout<<"Enter the string ";
cin.getline(ch,30);
cout<<"\n\n";
cout.write(ch,20);
cout<<"\n";
cout.good();
cout<<"\n";
cout.bad();
cout<<"\n";
cin.fill();a
cout<<"\n\n\nName : "<<ch;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int sum(int x=1 ,int y=2 , int z=3);
cout << " Sum= "<<sum(10,20,30)<<endl;
cout << " Sum= "<<sum(10,20)<<endl;
cout << " Sum= "<<sum(10)<<endl;
}
int sum(int x ,int y , int z)
{
return x+y+z;
}
#include<iostream>
#include<conio.h>
using namespace std;
int cal(int);
int cal(int ,int);
int cal(int ,int ,int);
float cal(float,int ,int);
int main()
{
int s,l,b,h,bS,ht;
float pi=3.143;
cout<<endl;
cout<<"TO FIND AREA OF SQUARE ................";
cout<<"\nEnter the length of the square:";
cin>>s;
cout<<"\nArea of the square is:"<<cal(s);
cout<<endl;
cout<<"\n\nTO FIND THE AREA OF RECTANGLE..........";
cout<<"\nlength of rectangle is:";
cin>>l;
cout<<"\nheight of rectangle is:";
cin>>h;
cout<<"\nbreadth of rectangle is:";
cin>>b;
cout<<"\nArea of the rectangle is:"<<cal(l,b,h);
cout<<endl;
cout<<"\n\nAREA OF TRIANGLE ..........................";
cout<<"\nbase of triangle is:";
cin>>bS;
cout<<"\nheight of triangle is:";
cin>>ht;
cout<<"\nArea of triangle is:"<<cal(pi,bS,ht);
getch();
return 0;
}
int cal(int x)
{
return ( x*x);
}
int cal(int x,int y,int z)
{
return (x*y*z);
}
float cal(float x,int y,int z)
{
return(x*y*z);
}
#include<iostream>
#include<conio.h>
using namespace std;
int disp(int ,int);
int main()
{
int a,b;
cout<<"Enter the two numbers:"<<endl;
cin>>a>>b;
disp(a,b);
getch();
return 0;
}
int disp(int x,int y)
{
cout<<"Additiis:"<<x+y;
}
#include<iostream>
#include<conio.h>
using namespace std;
//void add(void);
int sub(int ,int);
int main()
{
int a,b;
cout<<"enter the two variable:"<<endl;
cin>>a>>b;
// add();
sub(a,b);
getch();
return 0;
}
/*void add()
{
int x,y;
cout<<"addition is :"<<x+y;
}*/
int sub(int,int)
{
cout<<"substraction is:"<<a-b;
}
#include<iostream>
using namespace std;
int got(int ,int );
int main()
{
int a,b;
cout<<"enter the two nmbers:n";
cin>>a>>b;
got(a,b);
return 0;
}
int got(int x,int y)
{
int z =x+y;
cout<<"addition is :"<<z;
}
#include<iostream>
#include<conio.h>
using namespace std;
class student
{
int rno; //roll number
int s1,s2,s3,s; //nt marks s1,s2,s3
char name;
int total;
float percentage; //percentage
public:
void getData() //implicit fuction
{
cout<<"\n Entar the student roll number:";
cin>>rno;
cout<<"\n Enter the student name:";
cin>>name;
cout<<"\n Entar the marks of three subjects";
cin>>s1>>s2>>s3;
cout<<endl;
}
void calculate()
{
total=s1+s2+s3;
percentage=total/3;
}
void display()
{
cout<<"Roll no:"<<rno<<endl;
cout<<"name:"<<name<<endl;
cout<<"total marks:"<<total<<endl;
cout<<"percentage:"<<percentage;
}
};
int main()
{
student s;
s.getData();
s.calculate();
s.display();
getch();
}
#include<iostream>
#include<conio.h>
using namespace std;
int calC(int);
int calC(int , int);
int main()
{
int s,a,b;
cout<<"Enter the number";
cin>>s;
cout<<"square of "<<s<<" is"<<calC(s);
cout<<"Enter the two numbers:";
cin>>a>>b;
cout<<"addition of two numbers is:"<<calC(a,b);
getch();
return 0;
}
int calC(int x)
{
return(x*x);
}
int calC(int x,int y)
{
return(x+y);
}
#include<iostream>
#include<conio.h>
using namespace std;
int cal(int);
int cal(int ,int);
int cal(int ,int ,int);
float cal(float,int ,int);
int main()
{
int s,l,b,h,bS,ht;
float pi=3.143;
cout<<"TO FIND AREA OF SQUARE ................";
cout<<"\nEnter the length of the square:";
cin>>s;
cout<<"\nArea of the square is:"<<cal(s);
cout<<"\n\nTO FIND THE AREA OF RECTANGLE..........";
cout<<"\nlength of rectangle is:";
cin>>l;
cout<<"\nheight of rectangle is:";
cin>>h;
cout<<"\nbreadth of rectangle is:";
cin>>b;
cout<<"\nArea of the rectangle is:"<<cal(l,b,h);
cout<<"\n\nAREA OF TRIANGLE ..........................";
cout<<"\nbase of triangle is:";
cin>>bS;
cout<<"\nheight of triangle is:";
cin>>ht;
cout<<"\nArea of triangle is:"<<cal(pi,bS,ht);
getch();
return 0;
}
int cal(int x)
{
return ( x*x);
}
int cal(int x,int y,int z)
{
return (x*y*z);
}
float cal(float x,int y,int z)
{
return(x*y*z);
}
#include<iostream>
#include<conio.h>
using namespace std;
class test
{
int a;
public:
void getval_a();
void putval_a();
};
void test::getval_a(int x)
{
a=x;
}
void test::putval_a()
{
return a;
}
class result:public test
{
int b;
public:
void getval_b();
void putval_b();
};
void result::getval_b(int y);
{
b=y;
}
void result::putval_b()
{
return b;
}
class total:public test,public result
{
int c;
public:
void totalis();
void add();
};
void total::totalis(int z)
{
c=z;
c=a+b;
return c;
}
void total:add()
{
cout<<"addition is:"<<totalis();
}
int main()
{
total obj;
obj.getval_a(10);
obj.putval_a();
obj.getval_b(20);
obj.putval_b();
obj.totalis();
obj.add();
getch();
return 0;
}
#include<iostream>
#include<conio.h>
using namespace std;
int add(int ,int );
float div(int ,float );
char add(char ,char );
//double sub(int ,int );
//long multi(int ,int );
int add(int x,int y)
{
cout<<"addition is:"<<(x+y);
}
float div(int x,float y)
{
cout<<"dividation is:"<<(x/y);
}
char add(char x,char y)
{
cout<<"two strings:"<<x+y;
}
int main()
{
int a,b;
char c,d;
cout<<"enter the two numbers";
cin>>a>>b;
add(a,b);
div(a,b);
cout<<"Enter the two strings:"<<endl;
cin>>c>>d;
add(c,d);n
getch();
return 0;
}
#include<iostream>
#include<conio.h>
using namespace std;
class A;
class B
{
int b;
public:
void getval(int x)
{
b=x;
}
putval(void)
{
cout<<"\n Value of B is:"<<b;
}
friend void add(A,B);
};
class A
{
int a;
public:
void getval(int x)
{
a=x;
}
void putval(void)
{
cout<<"Value of A :"<<a;
}
friend void add(A,B);
}
void add(A obj1,B obj2)
{
cout<<"Addition of A and B is : "<<obj1.a+obj2.b;
}
int main();
A a;
B b;
a.getval(100);
b.getval(200);
a.putval();
b.putval();
add(a,b);
getch();
return 0;
#include<iostream>
#include<cmath>
void mauli(int ); //define
int main() //function
{ //double is a lareg number and real number
using namespace std;
int y;
mauli(y); //function call
cin.get();
system ("pause");
return 0;
}
void mauli(int x) //void means nothing
{
using namespace std;
cout<<"eneter the number :"<<endl;
cin>>x;
cout<<"my fave num is "<< x<<endl;
}
#include<iostream>
#include<conio.h>
using namespace std;
class test
{
int a,b;
public:
test(); //default constructoe
test(int x); //constructi0on with one argument
test(int x,int y); //construction with 2 arguments
void disp(); //member function of display the all of this data
};
test::test()
{
a=0;
b-0;
}
test::test(int x)
{
a=b=x;
}
test::test(int x,int y)
{
a=x;
b=y;
}
void test::disp() //function define
{
cout<<"\nValue of A : "<<a;
cout<<"\nValue of B : "<<b;
}
int main()
{
int a;
int b;
cout<<"\nEnter the values of a & b:\n";
cin>>a>>b;
test A; //efault constructor call
test B(a); //constructor call of one argument
test C(a,b); //construction call of two arguments
cout<<"\n\nObject A:\n";
A.disp();
cout<<"\n\nObject B:\n";
B.disp();
cout<<"\n\nObject C:\n";
C.disp();
getch();
return 0;
}
#include<iostream>
#include<conio.h>
using namespace std;
class like
{
float a,b,c;
public:
like();
like(int x,int y);
like(int x,int y,int z);
void disp();
};
like::like()
{
a=b=c=200;
}
like::like(int x,int y)
{
a=x+x;
b=y+y;
c=x+y;
}
like::like(int x,int y,int z)
{
a=z-y-x;
b=y-z;
c=z-y;
}
void like::disp()
{
cout<<"\nvalue of A is :"<<a;
cout<<"\nvalue of B is :"<<b;
cout<<"\nvalue of C is :"<<c;
}
int main()
{
like A;
like B(100,200);
like C(200,300,500);
cout<<"\nObject A";
A.disp();
cout<<"\nObject B";
B.disp();
cout<<"\nObject C";
C.disp();
getch();
return 0;
}
#include<iostream>
#include<conio.h>
using namespace std;
template<class T>
class mypair
{
T a,b;
public:
mypair(T first,T second)
{
a=first,b=second;
}
T getmax();
};
template <class T>
T mypair<T>::getmax()
{
T retval;
retval=a>b? a:b;
return retval;
}
int main()
{
mypair<int>myobject(100,75);
cout<<myobject.getmax() ;
getch();
}
#include<iostream>
using namespace std;
int main()
{
string str1,str3;
string str2="hello";
cout<<"enter the first string"<<endl;
cin>>str1;
cout<<"enter the second string:"<<endl;
cin>>str2;
if(str1.empty())
{
cout<<"string 1 is empty"<<endl;
}
else
{
cout <<"string is not empty"<<endl;
}
if(str2.empty())
{
cout<<"string 2 is empty."<<endl;
}
else
{
cout<<"strig 2 is not empty."<<endl;
}
string str="good morning";
char findout;
cout<<"string is:"<<str<<endl;
cout<<"enter the charactor you want to find:"<<endl;
cin>>findout;
cout<<"we find the "<<findout<< " "<<"at :"<<str.find(findout);
str=" I YOU ";
int a;
cout << "\nString is:"<<str<<endl;
str.insert(2," HATE ");
cout<<"\n\nString after the insert():"<<str<<endl;
str.replace(2,5," LOVE ");
cout<<"\n\nString after the replace ():"<<str;
cout<<"\nEnter the new string:"<<endl;
cin>>str1;
cout<<"\n What you want want to insert():"<<endl;
cin>>str2;
cout<<"On Which postion:";
cin>>a;
str.insert(a,str2);
cout<<"After the insertion:"<<str1;
str="helpdesk";
cout<<"string is :"<<str;
cout<<"length of the string is :"<<str.length();
cout<<"\n enter the string:"<<endl;
cin>>str1;
cout<<"\n enter the 2nd srinfg :"<<endl;
cin>>str2;
cout<<"\nlength of "<<str1<<" is:"<<str1.length();
cout<<"\n length of "<<str2<<" is :"<<str2.length();
cout<<"Enter the first string:";
getline(cin,str1);
cout<<"Enter the second string:";
getline(cin,str2);
if(str1==str2)
{
cout<<"strring are equal.";
}
else
{
cout<<"string are not equal.";
}
cout<<"Enter the first string:";
getline(cin,str1);
cout<<"Enter the second string:";
getline(cin,str2);
str3=str1+str2;
cout<<"new string is:"<<str3;
int b,c;
cout<<"enter the first integer :";
cin>>a;
cout<<"enter the second integer:";
cin>>b;
c=a-(-b);
cout<<"addo]ition is:"<<c;
if(cout<<"hello wlcome to c++ programming:")
{
}
str="good mornining";
cout<<"string is:"<<str<<endl;
str.erase(6);
cout<<"string after the earrase(): "<<str<<endl;
return 0;
}
#include<iostream>
using namespace std;
class classA
{
int a,b;
public:
void getValue(int , int);
void showValue();
};
void classA::getValue(int i,int j)
{
a=i;
b=j;
}
void classA::showValue()
{
cout<<"value of A is:"<<a<<endl;
cout<<"Value of B is: "<<b;
}
int main()
{
classA a;
a.getValue(5,10);
a.showValue();
return 0;
}
#include<iostream>
#include<conio.h>
using namespace std;
class test
{
int no;
static:
void getval(void);
static dispcount(void);
};
void test::getval(int x)
{
no=x;
cout<<"Number="<<no;
count++;
}
static void test::dispcount(void)
{
cout<<"counter="<<count;
}
int test::count;
int main()
{
test t1,t2,t3;
t1.dispcount();
t2.dispcount();
t3.dispcount();
t2.getval(100);
t2.getval(200);
t3.getval(300);
t1.dispcount();
t2.dispcount();
t3.dispcount();
getch();
return 0;
}