Showing posts with label C Plus Plus Programming. Show all posts
Showing posts with label C Plus Plus Programming. Show all posts

Sunday, 22 July 2018

C++ Program Classes Simple Example

Basically These are the Simple Example of  Classes in C++ Program

EXAMPLE:1

#include<iostream>
#include<conio.h>
using namespace std;
class myclass
{
private:
int a,b,c;
public:
void myfun()

{

a=10;
b=20;
c=a+b;
cout<<"Result is:"<<c;
}
};
int main()
{
        myclass obj;
obj.myfun();
getch();
return 0;

}
OUTPUT:-

Result is:30

EXAMPLE:-2

#include<iostream>
#include<conio.h>
using namespace std;
class myclass
{
public:
void myfun(int a,int b)
{
int c;
c=a+b;
cout<<"Result is:"<<c;
}
};
int main()
{
myclass obj;
obj.myfun(100,50);
getch();
return 0;
}
OUTPUT:-

Result is:150

Friday, 13 July 2018

C++ Program Ask To The User To Enter The Marks Obtained In 3 Subjects To Calculate and Display the Percentage Marks and Grade:

C++ Program Result card Sum,Percentage,Grade

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int sum,eng,math,bio,grade,percentage;
cout<<"Enter The marks of Eng:";
cin>>eng;
cout<<"Enter the marks of Math:";
cin>>math;
cout<<"Enter the marks of bio:";
cin>>bio;
sum=eng+math+bio;
cout<<sum;
percentage=(sum*100)/300;
cout<<endl<<percentage;
cout<<endl<<"Grade:";
if(percentage>=80)
{
cout<<"A";
}
else if(percentage>=70)
{
cout<<"B+";
}
else if(percentage>=60)
{
cout<<"B";
}
else if(percentage>=50)
{
cout<<"C";
}
else
{
cout<<"You are Failed";

}
cout<<endl<<"Thanks";
}

OUTPUT:-

Enter The marks of Eng:77
Enter the marks of Math:77
Enter the marks of bio:66
220
73
Grade:B+
Thanks

C++ Program Add,Product,Multipy


C++ Program Add,Product,Subtract:-

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a,b,c,sum,product,suntract;
a=10;
b=50;
c=a+b;
cout<<"SUM:";
cout<<c;
c=a*b;
cout<<endl<<"Product:";
cout<<c;
c=a-b;
cout<<endl<<"Subtract:";
cout<<c;

}
OUTPUT:-

SUM:60
Product:500
Subtract:-40

Tuesday, 10 July 2018

What is identifier in C++ Language



Identifiers:-


The Identifiers are the names used to represent Variable, constant, types, functions and label in the program. Identifier is an important feature of all computer languages. A good identifier name should be descriptive but short.

An identifier in C++ may consist of 31 character will be used. The remaining character will be ignored by C++ compiler. Some important rules for identifier name are as follows:

1. The first character must be an alphabetic or underscore ( ).

2. The identifier name must consist of only alphabetical characters, digits or underscores.

3. The reserved word cannot be used as identifier name.

Types Of Identifiers:-

C++ provides the following types of identifiers:
• Standard Identifiers
• User-defined identifiers
Standard Identifiers:-
A type of Identifier that has special meaning in C++ is Known as standard identifiers.

Example:-

Cout and cin are example of standard identifiers. These are the names of input/output object defined in standard input/output library iostream.h
User-defined Identifiers:-
The Type of identifiers that is defined by the programmer to acess memory location is known as user-defined identifier. is use to store data
Example:-
Some examples of user-defined identifiers are a, marks and age etc.

C++ Program Sum Of Two Number


Information Of this Program In Add Two Number:-

Sum Of Two Number in C++ First of all in this program C++ Program add two number start the header file include iostream then start the main function then the three variable declared the a,b,c the assign the value of a and assign the value of b the store the result in c variable then cout the result in screen

CODE:-

#include<iostream>

using namespace std;

int main()

{

int a,b,c;

a=20;

b=30;

c=a+b;

cout<<"Sum Of two number"<<c;

}

OUTPUT:-

Sum Of to number 50

C++ Program Swap Two Number


Learn about Swap Two Number:-

Swap Two Values In C++ First of all in this program swap two number first header file include iostream then start the main function three variable declared a,b and temp variable then user enter first number then first number store in a variable then user enter the second number then second number store the b variable then formula use to swap the number.

CODE:-

#include<iostream>

using namespace std;

int main()

{

int a,b,temp;

cout<<"Enter the first number:";

cin>>a;

cout<<"Enter the second number:";

cin>>b;

cout<<"you input the number as"<<a<<"and"<<b<<endl;

temp=a;

a=b;

b=temp;

cout<<"The Values after swapping are"<<a<<"and"<<b<<endl;

}

OUTPUT:-

Enter the first number:30
 Enter the second number:40 
 you input the number as 30 and 40 
 The Values after swapping are 40 and 30

Product Of Two Number in C++


Information Of This program Product Of two Number:-

Product Of Two Number in C++ First of all in this program C++ Program Product two number start the header file include iostream then start the main function then the three variable declared the a,b,c the assign the value of a and assign the value of b the store the result in c variable then cout the result in screen

CODE:-

#include<iostream>

using namespace std;

int main()

{

int a,b,c;


a=10;


b=10;


c=a*b;


cout<<"Product Of two number:"<<c;


}

OUTPUT:-

Product Of two number:100

History Of C++ Language and Features



Information Of C++ Language:-

Many new programming language appeared during the 1960s. The Computers at that time were still in early stage of development. The Language ALGOL 60  was developed as an alternative to FORTRAN. The Language CPL(combined programming language ) was developed in 1963. It was more specific for concrete programming tasks of that tome than ALGOL or FORTRAN. But it was very difficult  to learn .  Martin Richards developed BCPL (Basic Combined Programming Language) in 1967 that was simplification of CPL
it was originally named “C with Class” . it was enhancement to C language. It allows the use of a Programming technique  Known as Object oriented Programming (OOP).

Feature Of C++:-

  •  Convenient Language
  • Well-Structured Language
  • Case Sensitivity
  • Machine Independence
  • Object Oriented
  • Modular Programming
  • Standard Libraries
  • Hardware Control
  • Brevity
  • Speed
  • Popular Language
  • C Compatibility