N

@nileshww

arrays basics

C++
1 week ago
#include <iostream> using namespace std; int main() { int arr[5]; //number of elements in [] arr[0]=5; //giving each array its own value arr[1]=4; arr[2]=3; arr[3]=2; arr[4]=1;

power reccussion by dividing the power by 2 method

C++
1 week ago
#include <iostream> using namespace std; int pow(int a , int b){ int half; if(b==0 ) // base case return 1; half = pow(a,b/2); //calculation if(b%2==0){ //even and odd case

power recuursion

C++
1 week ago
#include <iostream> using namespace std; int pow(int a , int b){ if(b==0) return 1; return a*pow(a,b-1); } int main() {

fibonnaciii series (multiple call concept)

C++
2 weeks ago
#include <iostream> using namespace std; int fibo(int n){ if(n==1 || n==2) return 1; return fibo(n-1) + fibo(n-2); // fibonacci series is basically sum of n-1 and n-2 } int main() {

power reccursion

C++
2 weeks ago
#include <iostream> using namespace std; int pow(int a , int b){ if (b==0) //base case return 1; return a*pow(a,b-1); // power calculation } int main() {

reccursive fact

C++
2 weeks ago
#include <iostream> using namespace std; int fact(int n){ if(n==1) // break condition return 1; return n*fact(n-1); } int main() {

sum using reccursion

C++
2 weeks ago
#include <iostream> using namespace std; int sum(int n){ if (n==1) return 1; return n+sum(n-1); } int main() {

reverse reccursion

C++
4 weeks ago
#include <iostream> using namespace std; void print(int n){ if(n==0) return; //base function print(n-1); //call cout<<n<<endl; //work

reverse reccursion

C++
1 month ago
#include <iostream> using namespace std; void print( int n){ if(n==0) return; print(n-1); //calling the next function first before printing the next line cout<<n<<endl; // printing } int main() {

printing numbers using reccursion

C++
1 month ago
#include <iostream> using namespace std; void print(int n){ if(n==0) return; cout<<n<<endl; print(n-1); } int main() {

changing the value of x using pointers ( basically swapping numbers)

C++
1 month ago
#include <iostream> using namespace std; int main() { int x; cin>>x; int* p; p = &x; cout<<*p<<endl; //here printing *p because it will print the value of x by going to its address allocated in its memory

pointers printing integer value from the address of the int x

C++
1 month ago
#include <iostream> using namespace std; int main() { int x; cin>>x; int* p; p = &x; cout<<*p<<endl; //here printing *p because it will print the value of x by going to its address allocated in its memory

pointers (printing address of the number)

C++
1 month ago
#include <iostream> using namespace std; int main() { int x; cin>>x; int* p; // here to take the pointer we have to declare p with int* p=&x; cout<<&x<<endl; cout<<p<<endl;

printing address of a number stored in the ram

C++
1 month ago
#include <iostream> using namespace std; int main() { int x; cin>>x; cout<<&x<<endl; } // 0x7ffd26e94504 // 0x7ffe14476544

swapping numbers method 2

C++
1 month ago
#include <iostream> using namespace std; void swap(int& x , int& y){ int temp; temp = x; x=y; y=temp; } int main() {

esp testing

C++
1 month ago
#define LED_PIN 2 void setup() { pinMode(LED_PIN , OUTPUT); // put your setup code here, to run once: } void loop() { digitalWrite(LED_PIN , HIGH); delay(1000);

swapping numbers method 1

C++
1 month ago
#include <iostream> using namespace std; int main() { int x=2; int y=5; int temp; temp=x; x=y; y=temp;

pascal triangle

C++
1 month ago
#include <iostream> using namespace std; int fact(int x){ //here this function finds the factorial of the number feeded by the ncr function int f=1; for(int i=1; i<=x; i++){ f=f*i; } return f; }

permutation calculation

C++
1 month ago
#include <iostream> using namespace std; int fact(int x){ // here fact is the name int f = 1; for(int i =1; i<=x; i++){ f=f*i; } return f; }

void function basic

C++
1 month ago
#include <iostream> using namespace std; void india(){ cout<<"you r in india rn "<<endl; return; } void usa(){ india();