Posts

Showing posts with the label program

Top 5 Programming language need to learn in 2020

Image
Top 5 Programming Languages need to learn in 2020 If you're new to software development. The first question that comes to mind is where to start? This is probably true! There are hundreds of choices. How are you going to discover that this is the language I want to learn? What will be the most appropriate for you, your interests and your professional goals? One of the easiest ways to choose the best programming language to learn in 2020 is to listen to what the market says. Where the technology trend is heading ... What to learn in 2020 1. JavaScript Without Javascript, you cannot think of interactive web pages. That is the main reason JavaScript is so much popular among software developers. Today, it seems impossible to be a software developer without the use of JavaScript. First from the list is JavaScript, it seems impossible to imagine software development without JavaScript. In Stack Overflow 2018 for developers, JavaScript is the most widely used by developers in t

Tax calculating program in Python

Image
This program is used to calculate tax in the Python programming language. Tax calculating Program in Python This Tax calculating algorithm is very in this program we can improve this algorithm a lot. Note:  this is a very basic implementation of tax calculation. One should not use this to calculate the real tax to submit in real life, this is just a simulator for practice purposes. Algorithm:  First, we are asking for user input to get the total income and total saving, then we are checking for total taxable income by reducing savings from total_income. Then we are checking for various checks for tax bands. Implementation:  Code #code #Tax calculating program in python #By Rahul Rajput total_income=int(input("Please enter you total income: ")) print("700000") total_saving=int(input("Please enter you total saving: ")) print("50000") tax_exemption_limit=500000 tax_10_percent=750000 tax_20_percent=1000000 tax_30_percent=1250000 total_taxable_income

Bubble sort in Python Language

Image
Bubble sort is the simplest Sorting algorithm available. It works by repeatedly swapping the adjacent or neighbor element if they are in the wrong order. Working Actually in the first-pass bubble sort sets the largest element to its position, in the second pass algorithm sets the second largest element this continues till the list or array is not finally sorted. Here is the example image. To work with the algorithm you first have to understand what is swapping and how it is done. What is Swapping ?? Swapping is a technique to interchange the content of the two variables, using another variable called a temporary variable. In python programming language swapping works in two ways, both of them are shown below. For the program in Python arr = [64, 34, 25, 12, 22, 11, 90] n = len(arr) for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # traverse the array from 0 to n-i-1 # Swap if the element found is greater # than the next element if

Python program for Fibonacci series using Recursion

Image
What is the Fibonacci series The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. The 2 is found by adding the two numbers before it (1+1) The 3 is found by adding the two numbers before it (1+2), And the 5 is (2+3), and so on! Example: the next number in the sequence above is 21+34 =  55 code for Fibonacci series is terms = int(input("how many terms? : ")) #taking the input from the user #using recursion to print the series def recur_fibo(n,a1,a2): if n <= 1: #return this if terms is less than 1 print(a1) return else: print(str(a1) , end=" , ") return(recur_fibo(n-1,a2,a1 + a2)) #checking for the negative number and single terms if terms <= 0: print("Please enter a positive integer") elif terms == 1: print("Fibonacci Sequence of 1 terms : ") print(0) else: recur_fibo(terms,0,1) to veri

Creating Square, Rectangle, Multiply, slash using * (star) using C

Image
In the process of learning the basic of C language people often create shapes using the *, and these shapes question are also asked in the interview question and selection exam of various companies so it is very good to learn how to make various shapes. Rectangle we can also make multiply etc. Multiply Code for the above images it is in the order of images. #include <iostream> using namespace std; int main() { int size; cout << "Enter Number "; cin >> size; cout << endl; for(int i=0;i<size;i++){ for(int j=0;j<size;j++){ cout << "*"; } cout << endl; } cout << endl; for(int i=0;i<size;i++){ for(int j=0;j<size;j++){ if(i == j) cout << "*"; else cout << " "; } cout << endl; } cout << endl; for(int i=0;i<size;i++)

Selection Sort using C language (with every step)

Image
What is selection sorting The selection algorithm sorts an array by repeatedly finding the smallest element (considering increasing or ascending order) from the unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given group. 1) Subarray that is already sorted. 2) Remaining subarray that is unsorted. At each iteration of selection, the minimum value (with regard to rising order) is sorted from the unsorted subarray and moved to the sorted subframe. Code #include <stdio.h> void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } void selectionSort(int a[], int n) { int i, j, minIndex; printf("sorting array of length %d...\n",n); // n-1 changed to n for (i = 0; i < n; i++) { // in selection sort we find the smallest element // from array and put it aside, then we // find the next smallest in the remaining array // again, and go on and go on // pri

Calculating Julian Day Number (JDN) using C++

Image
what is Julian Day Number Julian Day is the continuous number of days since the beginning of the Julian period and is mainly used by astronomers and in software to easily calculate past days between two events (eg, food production date and sales by date). Code #include<iostream> #include <limits> using namespace std; void input_data(int &month, int &year, int &day,int &bmonth, int &byear, int &bday); void calculations(int month, int year, int day, int &jdn); void output_results(int &month, int &year, int &day, int &jdn,int d); void calculate_dow(int &jdn , int &dow); void calculate_difference_and_print(int jdn , int bjdn); void pause(); int main() { int bday; int bmonth; int byear; int bjdn; int day; int month; int year; int jdn; int dow; int bdow; input_data(month, year, day,bmonth, byear, bday); // calculate JDN for the present day calculations(month, year, day, jdn); // calculat

Bubble Sort in C language

Image
Bubble sort is the simplest Sorting algorithm available. It works by repeatedly swapping the adjacent or neighbor element if they are in the wrong order. Working Actually in first pass bubble sort sets the largest element to its position, in the second pass algorithm sets the second largest element this continues till the list or array is not finally sorted. Here is the example image. To work with the algorithm you first have to understand what is swapping and how it is done. What is Swapping ?? Swapping is the technique to interchange the content of the two variables, using another variable called temporary variable. For the program in C #include <stdio.h> void bubbleSort(int s[],int size){ int c,swap,d; for (c = 0 ; c < size - 1; c++) { for (d = 0 ; d < size - c - 1; d++) { if (s[d] > s[d+1]) /* For decreasing order use < */ { swap = s[d]; s[d] = s[d+1]; s[d+1] = swap

Distributed Systems AKTU (UPTU) lab program

Image
Distributed system DS is the subject mandatory subject in the seventh semester of the final year of Computer Science in Dr. APJ Abdul Kalam Technical University. Lab practical Questions. Assignment 1 Assignment 2 Assignment 3 Assignment 4 For the completed Answer of these assignments are in the link given below. Answers Thanks for being here. Subscribe to this blog for more post like this.

Blackjack Console game program in Python

Image
Console Games Games that can be played using the console. Here is the program for the Blackjack Game of the cards. BlackJack Game Blackjack  is the American variant of a globally popular  banking game  known as  Twenty-One. in this game, one player has to make the total sum of their hands to lower than 21 to win while another player has the total sum is 21 or more, All the cards greater than 10 are considered as the 10 and Ace is considered as the 11 or 1 depending on conditions. The person who has less total of the cards is the winner (one player should have scored more than 21). import random class blackJack: player1Hand = 0 player2Hand = 0 deck ={'Ace of Spades':1, '2 of Spades':2, '3 of Spades':3, '4 of Spades':4, '5 of Spades':5, '6 of Spades':6, '7 of Spades':7, '8 of Spades':8, '9 of Spades':9, '10 of Spades':10, 'Jack of Spades':10, 'Queen of Spades':10, 'King of

File Handling in C (Reading a file line by line)

Image
In this tutorial, we are working with the files in the C. File handling in any language requires Three main steps to follow Open the file in Read/Write mode. Do various operation that you want to do. Close the file. We are using fopen(file stream). there is some modes to open a file. Read mode  opens file into the read mode if file not found returns -1. Write mode opens file into the write mode if the file does not present creates a new file if there is previous data it will be overwritten. Append mode opens the file in the append mode and append data to it Without wasting much time lets start working. Create a New C file of whatever name you want mine is files.c. create the basic schema of C language. #include <stdio.h> int main(int argc, char const *argv[]) { /* code */ return 0; } Read From the file Create a FILE pointer to point a stream and open a file into the read mode using "r". you may need to include the string.h to your headers. the data of the file is #in

How to Use For Each loop in JavaScript

Image
For Each Loop In JavaScript Hello Guys, Having trouble in understanding the concept of the for each loop in javascript. or having trouble finding the correct source code. Then don't worry this post is for you. What is For Each Loop: this is the loop which automatically iterates through all the elements of an array, it helps in the working with the dynamic array. Let's start working. In javascript for-each loop works in a different way. Here we have to create a function which will be passed to the foreach function of the array. Enough discussion. Start working. First, create an array of names of the actor. var heros = ["Tony","Captain","Batman","SuperMan"] Now create the function with the logic that has to be passed in the for each loop. function myfunc(item){ console.log(item + " is a very good superhero"); }  Now call the function in the foreach function of array // running the foreach loop 4 times heros.forEach(myfunc); You c

TCP Socket Programming in Python (server/client)

Image
Socket Programming in Python What is Socket :  A  socket  is one end of a two-way communication link between two programs/software running on the network. A socket is bound to a port (also known as process id) number so that the TCP/UDP layer can identify the application that data to be transferred to. What to do? in order to create a server first, we need to create a socket in the program and put this socket into the listen mode. to that in the python is very easy, as you all know python is a very easy and powerful language. Socket Creation Create a New python file named as the server.py keep in mind that to work with socket we need to import socket into the file. import socket TCP_IP = '127.0.0.1' TCP_PORT = 15710 s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.bind((TCP_IP,TCP_PORT)) TCP_IP is the IP of this machine you are working on, and TCP_PORT is the port to be connected. socket.AF_INET is the protocol to work with the TCP protocol. Listening to connection and a

Easy File handling in C++ (working with files, fstream)

Image
In this tutorial, we are working with the files in the C++ or you have known to work with files as the file handling.  File handling in any language requires Three main step to follow Open the file in Read/Write mode. Do various operation that you want to do. Close the file. So In CPP, you can also use the traditional approach of C using FILE pointer and etc. We are using fstream (file stream). Without wasting much time lets start working. Create a New CPP file of whatever name you want mine is files.cpp. create the basic schema of cpp. #include <iostream> using namespace std; int main() { return 0; } To work with file add two more header first is #include<fstream>  , and second is #include<string> #include <fstream> #include <string> Now, let's start working with the writing into the files, to write into the file we need to open the file into the Write mode.  Which can be done by the ofstream class of cpp from the fstream header. string

Java Console Games Tutorial (number guessing by human)

Image
Java Console Gaming Welcome to the tutorial, this tutorial is all about the small console game which is small to play and write. suppose this program as the practice program, and try doing this on your own, this is highly recommended. if you are stuck somewhere or having any trouble you are free to look here on the page. Features and Rule of the game: Computer asks for a number in variable max number. Computer randomly generates a number and put this number as the guessed number. The computer asks the user to give a number between 0 to max number and reply back with the suitable answer like whether the entered number is lower or higher than the guessed number. you should also assign a variable for the max guess allowed which are 6 per game. When the user wins or lost the game a check for play again will be asked. The game is broken in two files GuessingGame.java and GuessingGameTester.java. GuessingGame.java holds mostly main logic for the game. And GuessingGameTester.java contains the