Generate Prime Numbers between 1 to N – Sieve of Eratosthenes

Write an efficient program to generate prime numbers between 1 to N (Where N is 10, 100, 1000 etc). This question can also be asked like this, Generate prime numbers between 1 to 100 or 1 to 10 etc.

Suppose the value of N is 10, So the prime numbers between 1 to 10 is 2, 3, 5, 7.  Now let’s learn the most efficient algorithm (Sieve of Eratosthenes) to generate Prime Numbers between 1 to N. Before solving this program, let’s understand what is a prime number.

MCQ on Recursion – Recursion Objective Questions for Practice

MCQ on Recursion

Recursion is the most important concept in computer science. In my previous posts, i have written about binary search implementation using recursion and difference between recursion and iteration.

These MCQ helps you to understand the concept of Recursion.

1) Which Data Structure is used to perform Recursion?

a) Queue
b) Stack
c) Linked List
D) Tree

Program to Swap two Numbers without temp or third variable

Program to swap two numbers without temp or third variable are very important in terms of interview. In swapping we exchange the position of two numbers. There are multiple ways in which you can swap two numbers . Some of them are

Write a Program to Swap two numbers using third variable.

Swap two numbers using Bitwise XOR Operator