Friday, 20 October 2023

Monday, 24 October 2022

Fundamentals of Variables

  Keywords:







Variables:

 

Every variable must have:

💬Data type
💬Name 
💬Size
💬value

Variable declaration:


Variable declaration:

Codes:

Data type sizes:


#include<iostream>
using namespace std;
int main()
{
cout<<"\nMemory Size of Data Types\n";
cout<<"Size Of short:"<<sizeof(short)<<endl; cout<<"Size Of short int:"<<sizeof(short int)<<endl;
cout<<"Size Of int:"<<sizeof(int)<<endl;
cout<<"Size Of Long int"<<sizeof(long int)<<endl;
cout<<"Size Of Long"<<sizeof(long)<<endl; cout<<"Size Of long long:"<<sizeof(long long)<<endl; cout<<"Size Of float:"<<sizeof(float)<<endl;
cout<<"Size Of double"<<sizeof(double)<<endl; cout<<"Size Of long double"<<sizeof(long double)<<endl;
}


Variable decleration:


#include<iostream>
using namespace std;

int main()
{

int age;  //variable declaration
age =30;  //assignment operation on variable age

int marks = 100; // variable definition i.e variable created as well as initialized

cout<<"age:"<<age<<" marks:"<<marks<<endl;


//overwriting previous values of variables age and marks

age = 31;
marks=98;

cout<<"Displaying new values of age and marks"<<endl;
cout<<"age:"<<age<<" marks:"<<marks<<endl;

}












C++ Programming from Problem Analysis to problem design, Ds Malik - 6th Addition.pdf

 



Click here to download Book.

BOOK URL

https://drive.google.com/file/d/11pdFEqRTBD0gukYZuUNlULHyMTkWAvdw/view?usp=sharing

Friday, 14 October 2022

Singly linked list

 

Singly Link list :

Insert at begining, at end and at given location code in C++


#include<iostream>
using namespace std;


class node
{
private:
int data;
node *next;
node *head;
node *ptr;
node *tail;
public:
node();
void insert_at_beg();
void insert_at_end();
void inset_at_loc(int loc);
void input_func();
    void display();
 
};

node::node()
{
next=head=ptr=NULL;
}
void node::input_func()
{
ptr=new node;
cout<<"Enter your data :";
cin>>ptr->data;
}
void node::insert_at_beg()
{
input_func();
if(head==NULL)
{
head=ptr;
ptr->next=NULL;
}
else
{
ptr->next=head;
head=ptr;
}
}
void node::insert_at_end()
{
input_func();
if(head==NULL)
{
head=ptr;
ptr->next=NULL;
}
else
{
node *temp=head;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=ptr;
}
}
void node::inset_at_loc(int loc)
{
input_func();
if(loc<=0)
{
cout<<"You entered invailed location"<<endl;
}
if(loc==1)
{
if(head==NULL)
{
head=ptr;
ptr->next=NULL;
}
else
{
ptr->next=head;
head=ptr;
}
}
else
{
node *temp=head;
for(int i=1;i<loc-1;i++)
{
temp=temp->next;
}
if(temp->next!=NULL)
{
ptr->next=temp->next;
temp->next=ptr;
}
else
{
temp->next=ptr;
ptr->next=NULL;
}
}
}
void node::display()
{
node *temp=head;
while(temp!= NULL)
{
cout<<"Data is :"<<temp->data<<""<<endl;
temp=temp->next;
}
}



int main()
{
node n;
n.insert_at_beg();
n.insert_at_beg();
n.insert_at_end();
n.inset_at_loc(2);
n.display();
return 0;
}

Thursday, 8 September 2022

C++ Syntax

                         C++ syntax:



Lets learn the code:
 
#include<iostream>
using namespace std;

int main()
{
     cout<<"Hello world"<<endl;
        return 0;
}

In this above code, 

In Line 1: #include<iostream> it is a library, it can work with input and output files. If we does not write this library then we see a syntax error because with the help of this we can give output and input.

In Line 2: using namespace std, it is used for scope of a function. and we can use names of objects and variables.

In Line 3: int main() , is the starting of a program , everything we write in main() means it will execute. and int is a data type. The Datatypes int, float, double, char, long double all return something. But a datatype void does not return anything.

In Line 4: cout<<"Hello World">>; it means it will execute and print Hello World. Cout means it will display the information.

In Line 5: return 0; it means  return type is int and int is a datatype that will return something so it returns 0.


Note: Every C++ statement ends with a semicolon. and blank spaces will be ignored.

It is a basic syntax for C++ .


Table example:

#include<iostream>
using namespace std;

int main()
{
cout<<"Table of 3"<<endl;
cout<<"-----------"<<endl;
cout<<"3*1="<<3*1<<endl;
cout<<"3*2="<<3*2<<endl;
cout<<"3*3="<<3*3<<endl;
cout<<"3*4="<<3*4<<endl;
cout<<"3*5="<<3*5<<endl;
cout<<"3*6="<<3*6<<endl;
cout<<"3*7="<<3*7<<endl;
cout<<"3*8="<<3*8<<endl;
cout<<"3*9="<<3*9<<endl;
cout<<"3*10="<<3*10<<endl;
}
 

Thursday, 1 September 2022

C++ Introduction 2022

 C++ Introduction:

C++ is a popular programming language, it is used to make computer programs and it is most used language in 2022.It is created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes".
C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for creating large-scale applications. C++ is a superset of the C language. A related programming language, Java, is based on C++ but optimized for the distribution of program objects in a network such as the Internet.




Example:

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World!";
  return 0;
}

Why use C++ in 2022:

It is a standard language within back-end development. It is an efficient language. It's in high demand now, and it will remain in high demand in 2022 because of its reliability, performance, and efficiency.
C++ is now one of the most widely used computer languages, with a wide range of applications. Python, Java, and web programming are all intriguing career paths, but C++ programmers are often overlooked and mistakenly believed to be dead.
C++ is portable and can be used to develop applications that can be adapted to multiple platforms.
C++ is fun and easy to learn!
As C++ is close to C# and Java, it makes it easy for programmers to switch to C++ or vice versa.
Difference between C and C++

C++ was developed as an extension of C, and both languages have almost the same syntax.

The main difference between C and C++ is that C++ support classes and objects, while C does not.





Fiver Account

 Fiver Account: https://www.fiverr.com/s/bPlNbN