Posts

Showing posts from May, 2020

DATA STRUCTURE Code PRACTICE (DSA)

Image
DATA STRUCTURE CODE PRACTICE :  Data Structure  is a way to store and organize  data  so that it can be used efficiently .  For example, we can store a list of items using array,linked list,stack,queue,tree,graph. Fibonacci series ---------------------------------------------------------------------- #include <iostream> using namespace std; int main() {     int n=10;     int a=0,b=1;     cout<<a<<" "<< b<<" ";     for(int i=1;i<=10;i++){         int nextNumber=a+b;         cout<<nextNumber<<" ";         a=b;         b=nextNumber;     } } Prime Number --------------------------------------------------------------------------------- #include <iostream> using namespace std; int main() { int n=7; bool isPrime=0; for(int i=2;i<n;i++){ if(n%i==0){ isPrime=1; break; //bcz if it not prime we need to break } } if(isPrime){ cout&