Posts

Showing posts from December, 2022

The if-else STATEMENTS in C++

Image
  The if-else STATEMENTS in C++ The if-else statements can control the flow of the code . For example, if you are 10 and only 10, you can play this game or else if you are 13 and only 13, you can play gta4 or else if you are 18+ , you can play any game else , you can't play From this, you can try and first guess, which ages won't be able to play games . Only ages 10,13 and 18+ can play at least some game. However, 9 and below and 11,12,14-17 can not play any games. This is how the flow control in a code works, now keep in mind, the syntax is if (condition) {} else if (condition) {} else {} Also, keep in mind, a==5 checks if a is 5 and returns true or false. a=5 initializes the value 5 to a. Try to print the output like this #include<bits/stdc++.h> using namespace std ; int  main () {     string username ;     cout<< "Enter your username - " ;     cin>>username ;          cout<<endl ;          cout<< "Welcome to ABC Online Bankin

Basic Syntax & First Code Build

Image
Basic Syntax & First Code Build Here is the syntax list for beginners to know how to start coding. Header Files #include<bits/stdc++.h> Function Syntax cin>> cout<< endl Data Type int string char double float Structure #include<bits/stdc++.h> using namespace std ; int  main () { //**ALL MAGIC HERE** --> Commented using '//' } The header file given above is usually enough for any code since it is a combined file of almost all C++ header files . The cin must have >> and cout must have  <<   and all code usually ends with a " ; " int accepts integer numbers between  -2,147,483,648 to 2,147,483,647 . string accepts inputs like agh3487bkk. You can guess and then check what the other data types do . With this knowledge, try and see if you can generate this output, if you just got started in C++, then see the code and get the idea and then try it on your own. #include<bits/stdc++.h> using namespace std ; int  main () {     

C++ Mindset & Understanding

Image
C++ Mindset & Understanding Welcome to the 45-minute course for C++ from 0 to PROJECT ready . In this segment of the article which happens to be the first video & read, we will cover the basic syntax in C++. To start with, you need to know what are the different types of syntaxes you will be learning in the next video & why they are in a particular order. We will also start working on our very own PROJECT. So not only will you finish a C++ course, but you will also have some experience. Code structure. Every code that will be written will have to follow certain patterns like Proper header files Proper functions The main function Proper declaration of variables Proper logic Respective Syntax Input Output Loops Manipulations Storage Others Now, how are each of them useful? Let's take a look at a sample project idea. Consider the banking management system . The intricacies of a banking system are so huge that it would compel us to think out of the box and uniquely. We will

Finding Factorial in C++ || Recursion

Image
 Finding Factorial in C++ || Recursion The logic and code are pretty simple for this. Considering that we don't have to do any exception handling. We get the input n. We return 1 if the input is 0 or 1. If the input is any other number (positive only) then we do recursion. The recursion is when we multiply the present number by the previous number and run the same function with this new result that we have. For example, try a dry run on your won for 5, See how it works for n=3 Iteration 1 in the function 3 != 1 or 0, so else case  return 3*factorial(2)    2 != 1 or 0, so else case return 3*2*(factorial(1))  1 == 1, so if-case return 3*2*1 = 6 So this is the logic behind the code. Here is the code, have fun, mess around and see what new things you can find in this.  #include<bits/stdc++.h> using namespace std ; int  factorial ( int  n ) {      if ( n== 1 ||n== 0 )          return   1 ;      else          return  n*factorial ( n -1 ); } int  main () {      int  n ;     cin>&

To check if input is a PALINDROME in C++

Image
Palindrome Checking in C++ Let's break this question down first. What is expected from us? We are to see if any input given to us is a palindrome or not. Now we consider the input to be proper, which means no exception handling will be required just yet. Now we need to check if the given input is the same whether read from left to right or from right to left. What is the logic? The inputs can be either string or int, so let's just go with the string data type , since it can also deal with int-based data. Now, we declare for loops, one will POINT to the first element and the SECOND will point to the last element. Let us have a conditional increment of the for loops, this way, the complexity of the code reduces. The algorithm! If the first and last elements are the same, then move to the second and last second element. If the second and last second elements are the same, then move to the third and last third elements. Do this until the pointers cross over. In any case, if the con

MAP Function in C++ STL

Image
  MAP Function in C++ STL The map function attributes values to certain keys. As can be seen above, the circle is matched with a circle, and so on. When the 'int' data type is attributed, the keys are automatically arranged in ascending order. The map can be manipulated in certain ways so that the value is always mapped to the key. So if you remove the key, the value is also removed. You move the key, and the value is also moved. Here is the syntax to create and display user-given inputs to a map. #include<bits/stdc++.h> using namespace std ; int  main () {     map< int , int > example ;      int  n , t1 , t2 ;          cin>>n ;           for ( int  i= 0 ; i<n ; i++ )      {         cin>>t1>>t2 ;         example.insert ( pair< int , int > ( t1 , t2 ));      }          cout<< "----------------------" <<endl ;          map< int , int > :: iterator i ;           for ( i=example.begin (); i!=example.end (); i++ )   

Data Centric Network (Unit 4)

Image
Data-Centric Network (Unit 4) Layer 2 Networking STP - Purpose Redundancy in layer 2 switches Loop intervention Better than redundant switch links STP - Loop free Elect root bridge Elect root ports Elected designated ports Elect alternate ports Ethernet Standards MSTI IEEE 802.3ba 40GB Ethernet VS 100GB Ethernet EVB TOR EOR VEB VEPA TRILL FCOE VS FCIP

Data Centric Network (Unit 5)

Image
 Data-Centric Network (Unit 5) IP Services IP Datagram IP Header Version - IPv4 or IPv6 Header Length - Storage of all required headers. Identification - Finding the datagram. Flags - Used under fragmentation. TTL - The time before the packet will be dropped. Protocol Header Checksum - Integrity of the data maintained. Options Padding IP Fragmentation IPv4 Issues No route aggregation - Minimize the routing table complexity. Address space exhaustion Lack of quality of service Limited mobility Security layer issue IPv6 Version number Flow label - Label packet requests handle by routers. Traffic class - Identification and marking class types of packet. Payload length Next header Hop limit Source address Destination address Flow Label  - Maintains  a table with an entry and exit definition for the IPv6 routing. IPv6 VS IPv4 Extension header types Hop by Hop Destination Source Routing Fragmentation Authentication ESP MPLS Link state routing & algorithms OSPF - Link state routing

Data Centric Network (Unit 3)

Image
  Data-Centric Network (Unit 3) Server Architecture Network Attachment - Interface for the communication between server and client via the network. Network Interface Cards - Provide connectivity between hosts. DMA - Transfers data without involving the system processor. Interrupt coalescing - Reduces the number of interrupts hence reducing delay. Jumbo frames - Support bigger ethernet frames. Server Multihoming Fault tolerance - Only one port is active which upon failure would keep it on standby and the other port take up the load. Load balancing - One port receives all the traffic. Link aggregation - A bunch of ports looks like a single link with equivalent bandwidth. PCI & PCI-X Buses - Bandwidth allocation of 533 MBPS & 1.066 GBPS. Client Server Packet Processing - How the OS handles the processing of IP packets. User mode VS Kernel mode - Interrupt handling & system services etc. Ethernet Driver Server TCP/IP Sockets Listen - Length of  receive queue of incoming