Skip to main content

Posts

Showing posts with the label programming

Different way to calculate prime number in c++

Three different ways to calculate the prime number in c++=> In this blog, we will see how to calculate given number is prime or not in o(N) time.  here we will see three different methods to check whether the given number is prime or not. Method 1=>  Run loop from 2 to n-1  we will run a loop from 2 to n-1 and if the number is divided by any number from 2 to n-1 we will return false that number is not a prime number otherwise we will return true. Time complexity => O(N) Method 2=> Run loop from 2 to n/2  we will run a loop from 2 to n/2 and if the number is divided by any number from 2 to n/2 we will return false that number is not a prime number otherwise we will return true. Time complexity => O(N/2) => O(N). This program will be faster than method 1 Method 3=>  Run a loop from 2 to root  √n   we will run a loop from 2 to  √n  and if the number is divided by any number from 2 to  √n   we will return false that number is not a prime number otherwise we will return

Reverse a number in c++ || C++ Program to Reverse a Number

 Reverse a number in c++ || C++ Program to Reverse a Number->    Write a program to reverse the digits of an integer. Input : num = 12345 Output: 54321 Input : num = 876 Output: 678 Algorithm: Input: num (1) Initialize rev_num = 0 (2) Loop while num > 0 (a) Multiply rev_num by 10 and add remainder of num divide by 10 to rev_num rev_num = rev_num*10 + num%10; (b) Divide num by 10 (3) Return rev_num

How to embed google form in your website ?

 How to embed Google form in your website ? Google Forms is a survey administration software included as part of the free, web-based Google Docs Editors suite offered by Google. The service also includes Google Docs, Google Sheets, Google Slides, Google Drawings, Google Sites, and Google Keep. Google Forms is only available as a web application. With Google Forms,  you can create and analyze surveys right in your mobile or web browser —no special software required. You get instant results as they come in. And, you can summarize survey results at a glance with charts and graphs. The benefit of using google form on your website - If your website is a static website and you don't want any server cost for your website you can use google form it will save your money and it is easy to implement as well. How to embed Google form in your website step by step- Go to Forms and open your form. Click Send. Next to Send via, click Embed  . Click the HTML and click Copy. Paste the HTML into your

What are promises in JavaScript ?

 What are promises in JavaScript ? Promises  are used to handle asynchronous operations in JavaScript. They are easy to manage when dealing with multiple asynchronous operations where callbacks can create callback hell leading to unmanageable code.  A  Promise  is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a  promise  to supply the value at some point in the future. A  Promise  is in one of these states: pending : initial state, neither fulfilled nor rejected. fulfilled : meaning that the operation was completed successfully. rejected : meaning that the operation failed.  Why do we need Promises? JavaScript is a single-threaded language  because while running code on a single thread, it can be real

How to create rotating Image animation in css ? How to create 360 degree rotating Image animation in css ?

 How to create rotating Image animation in CSS ? How to create 360-degree rotating Image animation in CSS ? What are CSS Animations? An animation lets an element gradually change from one style to another. You can change as many CSS properties you want, as many times as you want. To use CSS animation, you must first specify some keyframes for the animation. Keyframes hold what styles the element will have at certain times. Solution- We will add the CSS command to the element we wish to rotate in this example. You can adjust the  2s  to slow or speed up the rotation duration and rotate to 360 degrees in animation.

Logback can't write in console ? logback.xml solution.

Problem :  I am using Logback in my spring boot application.  The problem is logback do not print my logger messages in 'eclipse' console ? Solution ;- just reread the logback config doku. Actually, those two should inherit both appenders from root. So, what you can try is to not specify any appender-ref on those and see what happens. If no output is written to the file then, neither - then there is something pretty strange. I'd expect that behavior if the additivity flag was set to false. But the default is appender accumulation <logger name= "package.web" level= "INFO" > <appender-ref ref= "FILE" /> </logger> You need to add the console appender. <appender name= "STDOUT" class= "ch.qos.logback.core.ConsoleAppender" > <!-- By default , encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder --> <encoder> <pattern>

AN INTRODUCTION TO OPERATING SYSTEMS ? What is operating system ?

 AN INTRODUCTION TO OPERATING SYSTEMS  ? What is operating system ? There are two type of software Application software and System software  Application software performs specific task for the user. System software operates and controls the computer system and provides a platform to run application software. what is an operating system - An operating system is a piece of software that manages all the resources of a computer system,both hardware and software, and provides an environment in which the user can execute his/her programs in a convenient and efficient manner by hiding underlying the complexity of the hardware and acting as a resource manager. Why OS Needed in computers?  1. What if there is no OS?  a. Bulky  and  complex  app.  (Hardware  interaction  code  must be  in  app’s code base)  b. Resource exploitation by 1 App.  c. No memory protection.  2. What is an OS made up of?  a. Collection of system software.  The function of Operating system -  - Access to the computer har

How do I get today's date in JavaScript?

  How do I get today's date in JavaScript?- There are various methods that retrieve the date in JavaScript. The data values can get like years, months, days, hours, minutes, seconds, milliseconds from a Date Object.  What are different method provided by Date class in JavaScript-> Method Description getFullYear() Get the  year  as a four digit number (yyyy) getMonth() Get the  month  as a number (0-11) getDate() Get the  day  as a number (1-31) getHours() Get the  hour  (0-23) getMinutes() Get the  minute  (0-59) getSeconds() Get the  second  (0-59) getMilliseconds() Get the  millisecond  (0-999) getTime() Get the time (milliseconds since January 1, 1970) getDay() Get the weekday as a number (0-6) Date.now() Get the time. ECMAScript 5.

Implement stack Using array || how to implement stack c++

 Implement stack Using array || how to implement stack  In this blog, we will be implementing stack using array. What is stack?  A stack is a conceptual structure consisting of a set of homogeneous elements and is based on the principle of last in first out (LIFO). It is a commonly used abstract data type with two major operations, namely push and pop. Push and pop are carried out on the topmost element, which is the item most recently added to the stack. The push operation adds an element to the stack while the pop operation removes an element from the top position. The stack concept is used in programming and memory organization in computers. Operation in Stack -> Push:  Adds an item in the stack. If the stack is full, then it is said to be an Overflow condition. Pop:  Removes an item from the stack. The items are popped in the reversed order in which they are pushed. If the stack is empty, then it is said to be an Underflow condition. Peek or Top:  Returns the top element of the

bubble sort algorithm in c++ || Bubble sort explained || sinking sort

 Bubble sort- Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The pass of the list is repeated until the list is sorted. Why bubble sort is called “bubble” sort? The “bubble” sort is called so  because the list elements with greater value than their surrounding elements “bubble” towards the end of the list . For example, after first pass, the largest element is bubbled towards the right most position. Worst complexity :  n^2 Average complexity :  n^2 Best complexity :  n Space complexity :  1 at the end of i th pass, we have the i th largest element placed at its correct place. look the example below. Example:   First Pass:   (  5   1  4 2 8 ) –> (  1   5  4 2 8 ) ( 1  5   4  2 8 ) –>  ( 1  4   5  2 8 ) ( 1 4  5   2  8 ) –>  ( 1 4  2   5  8 ) ( 1 4 2  5   8  ) –> ( 1 4 2  5   8  ) 1st largest placed at the correct place. Second

What is an algorithm in computer science ?

 What is an algorithm in computer science ?- You may have heard the term  algorithm  recently, whether it was online or perhaps in some conversation about technology. It's a word that gets thrown around a lot, but what does it mean exactly? suppose your mom gave you a task to prepare a cup of tea for her. How do you prepare a cup of tea for her ? definitely, to prepare a cup of tea you are gonna follow the following steps 1- Boil water. 2- Warm up teapot 3-  Put the tea into a teapot and add hot water. 4- Cover teapot and steep tea 5- Strain tea solids and pour hot tea into tea cups. Basically preparing tea was a problem and you follow some step-by-step procedures to solve this problem.  similarly, in computer science,  An algorithm is simply a  set of steps used to complete a specific task . They're the building blocks for programming, and they allow things like computers, smartphones, and websites to function and make decisions. An algorithm is a specific procedure for solvin