Posts

Difference between Compile Time and Run Time

  Compile Time :  It is a Time window During which a Program is Compiled. During Compilation , a source code or program is converted into machine code. There are two types of errors in Compile Time known as Compile Time errors : Syntax Error Semantic Error Syntax Error :  The Error occurs due to mistake in syntax or predefined way of writting a programm during compilation is called Syntax Error. Example :  #include<iostream> using namespace std; int main() {     int a = 10:        // Every statement should be ended with an ' ; ' (semicolon) , but here it is ended with                              // ' : ' (colon) it is an syntax error .     int b = 20;     return 0; } Semantic Error :  The wrong and meaningless code/statement in a programm are called Semantic Errors. Example :  int main() {...

OOP vs POP

Image
  OOP(Object Oriented Programming) OOP is a type of language which works on concept of Objects. Object is the instance of classes which is created to initialize Classes, when classes are initialize the memory is allocated to them. In OOP a program is sub-divided into objects Example Of OOP languages : C++, C#, Python, Java, VB.net etc. POP(Procedural Oriented Programming) POP is a type of programming language which works on the concept of functions. In POP a program is sub-divided into functions. Example of POP languages : C, COBOL, BASIC, FORTRAN etc. Difference between OOP and POP : source : www.journeywithranjan.blogspot.com

C++ Programming Language Easy Course

Image
C++ C++ is a low level general purpose programming language, It was developed by Danish scientist Bjarne stroustrup as an extension of the C programming language. Bjarne Stroustrup in his Lab source : https://img.gfx.no/2582/2582098/Bjarne%20Stroustrup.1000x563.jpg It has all the features of C language but Unlike C it is Not un Procedural Oriented Language it is an Object Oriented Programming Language that's why It is often called 'C with classes'. Object Oriented Programming language(OOP) Object Oriented Programming Languages are those Programming languages which uses the concept of 'Ojects'. These Objects contain Data in the form of  Attributes and Codes in the form of Methods or Behaviour. For example : A person Has basic propertiese like Name, age and height these are called attributes and the behaviour of person includes walking, talking and doing any work. Class A Class is an user defined data type which contains data members and member functions. It is de...

A program to Add numbers divisible by 3 or 5 in C++

Problem - To find the sum of numbers divisible by 3 or 5. Input- 20 Output- Numbers divisible by 3 or 5 are given below 3 5 6 9 10 12 15 18 20 The sum of numbers divisible by 3 or 5 is - 98 Program - #include<iostream> using namespace std; int main() {     int num;     cout<<"Enter the number ";     cin>>num;     int sum=0;     cout<<"\nThe numbers divisible by 3 or 5 are given below "<<endl;     for(int x=0;x<num;x++)     {         if(x%3==0)         {             cout<<x<<endl;             sum=sum+x;         }         else if(x%5==0)         {             cout<<x<<endl;             sum=sum+x;         }     } ...

Write a program that asks the user for a number n and prints the sum of the numbers 1 to n.

Input :   100 Output :   The sum of numbers from 1 to 100 is : 5050 Program: #include<iostream> using namespace std; //Write a program that asks the user for a number n and prints the sum of the numbers 1 to n. int main() {     int n,sum;     cout<<"Enter the number : ";     cin>>n;     sum=(n)*(n+1)/2;     cout<<"The sum of numbers from 1 to "<<n<<" is : "<<sum;     return 0; }

When only Some specific user name will be greeted in a C++ Program.

Modification of previous program. Program: #include<iostream> #include<string> //here string file is used to use string reserved keyword using namespace std; int main() {     string Name, response;     cout<<"Please give Your name : ";     getline(cin, Name); //getline is used to store character entered after space button is clicked     if((Name=="Alice")||(Name=="Bob"))  //Here || is logical OR operator.     {         cout<<"Namaste, "<<Name;     }     else     {         cout<<"You are out of the program";     }     return 0; } Note : If you want to see the previous program then click here PROGRAM

A program that asks the user for their name and greets them with their name.

If you want to display Full Name in C++ than you are on a right place. Example: #include<iostream> #include<string> using namespace std; int main() {     string name;     cout<<"Please give Your name : ";     getline(cin, name);     cout<<"Namaste, "<<name;     return 0; } Output: Please give Your name : Rudra Pratap Singh Namaste, Rudra Pratap Singh