#include<iostream> #include<iomanip> using namespace std; int main(){ int num,i,count,n; cout << "Enter max range: "; cin >> n; for(num = 1;num<=n;num++){ count = 0; for(i=2;i<=num/2;i++){ if(num%i==0){ count++; break; } } if(count==0 && num!= 1) cout << num << setw(3); } system("pause"); return 0; }
Search
12 May, 2016
PRIME NUMBERS WITH IN THE GIVEN RANGE
Sort Elements in Lexicographical Order
#include<iostream>
#include <cstring>
using namespace std;
int main(){
int i,j;
char str[10][50],temp[50];
cout << "Enter 10 words: " << endl;
for(i=0;i<10;++i)
cin.getline(str[i], 50);
for(i=0;i<9;++i)
for(j=i+1;j<10 ;++j){
if(strcmp(str[i],str[j])>0)
{
strcpy(temp,str[i]);
strcpy(str[i],str[j]);
strcpy(str[j],temp);
}
}
cout << "In lexicographical order: " << endl;
for(i=0;i<10;++i){
cout << str[i] << endl;
}
return 0;
}
Enter 10 words:
fortran
java
perl
python
php
javascript
c
cpp
ruby
csharp
In lexicographical order:
c
cpp
csharp
fortran
java
javascript
perl
php
python
ruby
11 May, 2016
Cache memory
A Cache (Pronounced as “cash”) is a small and very fast temporary storage memory. It is designed to speed up the transfer of data and instructions. It is located inside or close to the CPU chip. It is faster than RAM and the data/instructions that are most recently or most frequently used by CPU are stored in cache.
The data and instructions are retrieved from RAM when CPU uses them for the first time. A copy of that data or instructions is stored in cache. The next time the CPU needs that data or instructions, it first looks in cache. If the required data is found there, it is retrieved from cache memory instead of main memory. It speeds up the working of CP
26 April, 2016
Important programming concept for exam
C++ virtual function:
http://www.learncpp.com/cpp-tutorial/122-virtual-functions/
http://www.learncpp.com/cpp-tutorial/122-virtual-functions/
26 March, 2016
What is DNS, why it is important and how it works
But why is DNS important? How does it work? What else should you know?
Why is DNS important?
DNS is like a phone book for the Internet. If you know a person’s name but don’t know their telephone number, you can simply look it up in a phone book. DNS provides this same service to the Internet.When you visit http://dyn.com in a browser, your computer uses DNS to retrieve the website’s IP address of 204.13.248.115. Without DNS, you would only be able to visit our website (or any website) by visiting its IP address directly, such as http://204.13.248.115.
How does DNS work?
When you visit a domain such as dyn.com, your computer follows a series of steps to turn the human-readable web address into a machine-readable IP address. This happens every time you use a domain name, whether you are viewing websites, sending email or listening to Internet radio stations like Pandora.
Step 1: Request information
The process begins when you ask your computer to resolve a hostname, such as visiting http://dyn.com. The first place your computer looks is its local DNS cache, which stores information that your computer has recently retrieved.
If your computer doesn’t already know the answer, it needs to perform a DNS query to find out.
Step 2: Ask the recursive DNS servers
If the information is not stored locally, your computer queries (contacts) your ISP’s recursive DNS servers. These specialized computers perform the legwork of a DNS query on your behalf. Recursive servers have their own caches, so the process usually ends here and the information is returned to the user.
Step 3: Ask the root nameservers
If the recursive servers don’t have the answer, they query the root nameservers. A nameserver is a computer that answers questions about domain names, such as IP addresses. The thirteen root nameservers act as a kind of telephone switchboard for DNS. They don’t know the answer, but they can direct our query to someone that knows where to find it.
Step 4: Ask the TLD nameservers
The root nameservers will look at the first part of our request, reading from right to left — www.dyn.com — and direct our query to the Top-Level Domain (TLD) nameservers for .com. Each TLD, such as .com, .org, and .us, have their own set of nameservers, which act like a receptionist for each TLD. These servers don’t have the information we need, but they can refer us directly to the servers that do have the information.
Step 5: Ask the authoritative DNS servers
The TLD nameservers review the next part of our request — www.dyn.com — and direct our query to the nameservers responsible for this specific domain. These authoritative nameservers are responsible for knowing all the information about a specific domain, which are stored in DNS records. There are many types of records, which each contain a different kind of information. In this example, we want to know the IP address for www.dyndns.com, so we ask the authoritative nameserver for the Address Record (A).
Step 6: Retrieve the record
The recursive server retrieves the A record for dyn.com from the authoritative nameservers and stores the record in its local cache. If anyone else requests the host record for dyn.com, the recursive servers will already have the answer and will not need to go through the lookup process again. All records have a time-to-live value, which is like an expiration date. After a while, the recursive server will need to ask for a new copy of the record to make sure the information doesn’t become out-of-date.
Step 7: Receive the answer
Armed with the answer, recursive server returns the A record back to your computer. Your computer stores the record in its cache, reads the IP address from the record, then passes this information to your browser. The browser then opens a connection to the webserver and receives the website.
This entire process, from start to finish, takes only milliseconds to complete.
21 March, 2016
Type of Algorithms
Divide and conquer algorithms
• String Reconstruction
• Longest Common Subsequence
• Edit Distance
• Subset Sum
Greedy Algorithm
- Binary Search
- Quick Sort
- Merge Sort
- Integer Multiplication
- Matrix Multiplication (Strassen's algorithm)
- Maximal Subsequence
• String Reconstruction
• Longest Common Subsequence
• Edit Distance
• Subset Sum
Greedy Algorithm
- Kruskal’s Minimum Spanning Tree (MST):
- Prim’s Minimum Spanning Tree
- Dijkstra’s Shortest Path
- Huffman Coding
11 February, 2016
04 February, 2016
Python
Class object:
file name media.py
##############
import webbrowser
class Movie():
def __init__(self, movie_title, movie_storyline, poster_image,
trailer_youtube):
self.title = movie_title
self.storyline = movie_storyline
self.poster = poster_image
self.trailer = trailer_youtube
def show_trailer(self):
webbrowser.open(self.trailer)
#############
trailller.py
import class_object
movie_story = class_object.Movie("Toy story", "something missing", "image url ",
"youtube.com")
print(movie_story.storyline)
movie_story.show_trailer()
###################
Read from url:
def read_web_page():
connection = urllib.request.urlopen(
"http://manozbiswas.blogspot.com/2016/02/nice-drawing-in-python.html")
output = connection.read()
print(output)
connection.close()
read_web_page()
#################
Read from file:
def readText():
quotes = open(r"C:\Users\manoz debnath\Desktop\py\hello.txt")
contents = quotes.read()
print(contents)
quotes.close()
readText()
######################
Drawing image:
import turtle
def drawSquare(some_turtle):
for i in range(1, 5):
some_turtle.forward(100)
some_turtle.right(90)
def drawArt():
window = turtle.Screen()
window.bgcolor("red")
# Create the turtle Brad -Draws square brad = turtle.Turtle()
brad.shape("turtle")
brad.color("yellow")
brad.speed(2)
for i in range(1,37):
drawSquare(brad)
brad.right(10)
#Create turtle Angie - Draws a circle
# angie = turtle.Turtle()
# angie.shape("arrow")
# angie.color("blue")
# angie.circle(100)
window.exitonclick()
drawArt()
#######################
Draw a square with a circle:
#################
import turtle def drawSquare(): window = turtle.Screen() window.bgcolor("red") brad = turtle.Turtle() brad.shape("turtle") brad.color("yellow") brad.speed(2) brad.forward(100) brad.right(90) brad.forward(100) brad.right(90) brad.forward(100) brad.right(90) brad.forward(100) brad.right(90) angie = turtle.Turtle() angie.shape("arrow") angie.color("blue") angie.circle(100) window.exitonclick() drawSquare()
###################
03 February, 2016
Challenge and Mistakes in ERP Implementation
It is very important, that implementation is done in stages. Trying to implement everything at once will lead to a lot of confusion and chaos.
- Appropriate training is very essential during and after the implementation. The staff should be comfortable in using the application or else, it will backfire, with redundant work and functional inefficiencies.
- Lack of proper analysis of requirements will lead to non-availability of certain essential functionalities. This might affect the operations in the long run and reduce the productivity and profitability.
- Lack of Support from Senior Management will lead to unnecessary frustrations in work place. Also, it will cause delay in operations and ineffective decisions. So, it is essential to ensure that the Senior Management supports the transformation.
- Compatibility Issues with ERP Modules lead to issues in integration of modules. Companies associate different vendors to implement different ERP modules, based on their competency. It is very essential that there is a way to handle compatibility issues.
- Cost Overheads will result, if requirements are not properly discussed and decided during the planning phase. So, before execution, a detailed plan with a complete breakdown of requirements should be worked out.
- Investment in Infrastructure is very essential. ERP applications modules will require good processing speed and adequate storage. Not allocating suitable budget for infrastructure will result in reduced application speed and other software issues. Hardware and Software Security is also equally important.
13 Common ERP Mistakes and How to
Avoid Making Them
- RP Mistake #1: Poor planning
- ERP Mistake #2: Not properly vetting ERP vendors.
- ERP Mistake #3: Not understanding or using key features.
- ERP Mistake #4: Underestimating the time and resources required.
- ERP Mistake #5: Not having the right people on the team from the start
- ERP Mistake #6: Not setting priorities
- ERP Mistake #7: Not investing in training and change management.
- ERP Mistake #8: Underestimating the importance of accurate data
- ERP Mistake #9: Taking the kitchen sink approach.
- ERP Mistake #10: Not decommissioning legacy applications.
- ERP Mistake #11: Not having an active load testing environment
- ERP Mistake #12: Ignoring third-party support alternatives
- ERP Mistake #13: Not having a maintenance strategy.
E-R Diagram
E-R Diagram: Best Design
An entity–relationship diagram using Chen's notation
Symbols:
Derived attributes are depicted by dashed ellipse.
Cardinality Relationship:
Relationship with foreign key
Generalization:Generalization is a bottom-up approach in which two lower level entities combine to form a higher level entity. In generalization, the higher level entity can also combine with other lower level entity to make further higher level entity
Specialization:Specialization is opposite to Generalization. It is a top-down approach in which one higher level entity can be broken down into two lower level entity. In specialization, some higher level entities may not have lower-level entity sets at all.
Aggregration: Aggregration is a process when relation between two entity is treated as a single entity. Here the relation between Center and Course, is acting as an Entity in relation with Visitor.
An entity–relationship diagram using Chen's notation
Symbols:
Cardinality Relationship:
Relationship with foreign key
Participation Constraints
- Total Participation − Each entity is involved in the relationship. Total participation is represented by double lines.
- Partial participation − Not all entities are involved in the relationship. Partial participation is represented by single lines.
Generalization:Generalization is a bottom-up approach in which two lower level entities combine to form a higher level entity. In generalization, the higher level entity can also combine with other lower level entity to make further higher level entity
Specialization:Specialization is opposite to Generalization. It is a top-down approach in which one higher level entity can be broken down into two lower level entity. In specialization, some higher level entities may not have lower-level entity sets at all.
Aggregration: Aggregration is a process when relation between two entity is treated as a single entity. Here the relation between Center and Course, is acting as an Entity in relation with Visitor.
![]() |
31 January, 2016
Connection Class in c# windows form
//Method one
using System.Data.SqlClient;
class myConnection
{
public static SqlConnection GetConnection()
{
string str = "Data Source=MANOZ\\SQLEXPRESS;Initial Catalog=softworksbd;Integrated Security=True;";
SqlConnection con = new SqlConnection(str);
con.Open();
return con;
}
}
30 January, 2016
Flow chart and code to find the largest number among three integer
#include <iostream>
using namespace std;
int main() {
float n1, n2, n3;
cout << "Enter three numbers: ";
cin >> n1 >> n2 >> n3;
if (n1 >= n2) {
if (n1 >= n3) {
cout << "Largest number: " << n1;
}
else {
cout << "Largest number: " << n3;
}
}
else {
if (n2 >= n3) {
cout << "Largest number: " << n2;
}
else {
cout << "Largest number: " << n3;
}
}
return 0;
}
29 January, 2016
Why RAM is Faster than Hard Disk
Hard Drive requires the sequential translation of information from an electro-mechanical
medium to a logical medium
RAM requires a sequential read from one logical medium to another logical medium to another.
Performance of hard disk is specified by the time required to move the heads to a track or cylinder (average access time) plus the time it takes for the desired sector to move under the head (average latency, which is a function of the physical rotational speed in revolutions per minute), and finally the speed at which the data is transmitted (data rate). In RAM the time required to read and write data items varies depending on their physical locations on the recording medium, due to mechanical limitations such as media rotation speeds and arm movement delays.
Every time you open a program, it gets loaded from the hard drive into the RAM. This is because reading data from the RAM is much faster than reading data from the hard drive. Running programs from the RAM of the computer allows them to function without any lag time. The more RAM your computer has, the more data can be loaded from the hard drive into the RAM, which can effectively speed up your computer. In fact, adding RAM can be more beneficial to your computer’s performance than upgrading the CPU.
medium to a logical medium
RAM requires a sequential read from one logical medium to another logical medium to another.
Performance of hard disk is specified by the time required to move the heads to a track or cylinder (average access time) plus the time it takes for the desired sector to move under the head (average latency, which is a function of the physical rotational speed in revolutions per minute), and finally the speed at which the data is transmitted (data rate). In RAM the time required to read and write data items varies depending on their physical locations on the recording medium, due to mechanical limitations such as media rotation speeds and arm movement delays.
Every time you open a program, it gets loaded from the hard drive into the RAM. This is because reading data from the RAM is much faster than reading data from the hard drive. Running programs from the RAM of the computer allows them to function without any lag time. The more RAM your computer has, the more data can be loaded from the hard drive into the RAM, which can effectively speed up your computer. In fact, adding RAM can be more beneficial to your computer’s performance than upgrading the CPU.
27 January, 2016
Generation of prime number in c
#include<stdio.h>
#include<conio.h>
int main()
{
int num, n, div, p;
printf("Enter any number: ");
scanf("%d", &num);
for(n = 2; n <= num; n++)
{
for(div = 2; div < n; div++)
{
if(n % div == 0)
{
p = 0;
break;
}
p = 1;
}
if(p)
printf("%d ",n);
}
return 0;
}
Generation of prime number in c
#include<stdio.h>
#include<conio.h>
int main()
{
int num, n, div, p;
printf("Enter any number: ");
scanf("%d", &num);
for(n = 2; n <= num; n++)
{
for(div = 2; div < n; div++)
{
if(n % div == 0)
{
p = 0;
break;
}
p = 1;
}
if(p)
printf("%d ",n);
}
return 0;
}
Generation of prime number in c
#include<stdio.h>
#include<conio.h>
int main()
{
int num, n, div, p;
printf("Enter any number: ");
scanf("%d", &num);
for(n = 2; n <= num; n++)
{
for(div = 2; div < n; div++)
{
if(n % div == 0)
{
p = 0;
break;
}
p = 1;
}
if(p)
printf("%d ",n);
}
return 0;
}
Generation of Prime Number in c++ according to sieve algorithm
/*
Name: Manoz Kumar Biswas
E-mail: manozcsejust@gmail.com
Start Date: 08-03-2015
Date Update:
Purpose: TO generate a long list of prime number by dynamic programming approach
Input: a list of integer numbers
Output: a list of prime numbers among the integers
*/
#include <iostream>
#include <cmath>
using namespace std;
#define SIZE 121
long int primeList[SIZE];
int main()
{
//cout << sizeof primeList;
for(long int i = 2; i < SIZE; i++)
{
primeList[i] = 1; //at first we assume all is prime and all the position is marked by 1
}
for(long int i = 2; i <= sqrt(SIZE); i++)
{
if(primeList[i] == 1)
{
for(long int j = i + i; j < SIZE; j = j + i)
{
if(primeList[j] != 0){
primeList[j] = 0; //all the multiples of i are set to 0 to indicate not prime
}
}
}
}
cout << "The list of prime numbers till 121 is" << endl;
for(long int i = 2; i <= SIZE; i++)
{
if(primeList[i] == 1)
{
cout << i << " "; //shows only the position that are prime indicated by 1
}
}
return 0;
}
Factorial in c++
#include <iostream>
using namespace std;
int main() {
int i, n, factorial = 1;
cout<<"Enter a positive integer: ";
cin>>n;
for (i = 1; i <= n; ++i) {
factorial *= i; // factorial = factorial * i;
}
cout<< "Factorial of "<<n<<" = "<<factorial;
return 0;
}
//Using recursion
#include<iostream>
#include<conio.h>
using namespace std;
//Function
long factorial(int);
int main()
{
// Variable Declaration
int counter, n;
// Get Input Value
cout<<"Enter the Number :";
cin>>n;
// Factorial Function Call
cout<<n<<" Factorial Value Is "<<factorial(n);
// Wait For Output Screen
getch();
return 0;
}
// Factorial recursion Function
long factorial(int n)
{
if (n == 0)
return 1;
else
return(n * factorial(n-1));
}
Fibonacci series in c++
#include<iostream> using namespace std; int main(){ int n, first = 0, second = 1, third; cout<< "enter the number of terms " << endl; cin >> n; cout << "first "<< n << " fibonaccy series"<< endl; for(int i = 1; i <= n ; i++){ if(i <= 1){ third = i; } else{ third = first + second; first = second; second = third; } cout << third << " "; } return 0; }
First 6 fibonacci series are
1 1 2 3 5 8
25 January, 2016
Friend functions
In principle, private and protected members of a class cannot be
accessed from outside the same class in which they are declared.
However, this rule does not apply to "friends".
Friends are functions or classes declared with the
A non-member function can access the private and protected members of a class if it is declared a friend of that class. That is done by including a declaration of this external function within the class, and preceding it with the keyword
Friends are functions or classes declared with the
friend
keyword.A non-member function can access the private and protected members of a class if it is declared a friend of that class. That is done by including a declaration of this external function within the class, and preceding it with the keyword
friend
:
// friend functions
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
Rectangle() {}
Rectangle (int x, int y) : width(x), height(y) {}
int area() {return width * height;}
friend Rectangle duplicate (const Rectangle&);
};
Rectangle duplicate (const
Rectangle& param)
{
Rectangle res;
res.width = param.width*2;
res.height = param.height*2;
return res;
}
int main () {
Rectangle foo;
Rectangle bar (2,3);
foo = duplicate (bar);
cout << foo.area() << '\n';
return 0;
}
The duplicate function is a friend
of class Rectangle. Therefore,
function duplicate is able to
access the members width and height
(which are private) of different
objects of type Rectangle.
Notice though that neither in the
declaration of duplicate nor
in its later use in main, function
duplicate is considered a member
of class Rectangle. It isn't! It simply
has access to its private
and protected members without being a
member.
}
Subscribe to:
Posts (Atom)