Structures in C++ and Pointer

 #include <iostream>

using namespace std;

struct Rectangle

{

    int length;

    int breadth;

};

int main()

{

    struct Rectangle r= {20,10};

    struct Rectangle *p=&r;//struct type pointer

    r.length=30;//accessing struct variable

    (*p).breadth=15;// accessing with pointer

    p->length=100;

    \ dot er alternative for pointer

    cout<<“Breadth:”<<r.breadth<<“Length:”<<r.length<<endl;

}

1 thought on “Structures in C++ and Pointer”

  1. #include
    using namespace std;

    int evv_odd(int n)
    {
    if(n%2==0)
    {
    cout<<"Given number Even"<> n;

    if (n < 0)
    cout << "Error! Factorial of a negative number doesn't exist.";
    else {
    for(int i = 1; i <= n; ++i) {
    factorial *= i;
    }
    cout << "Factorial of " << n << " = " << factorial;
    }

    }
    int main(){
    //evv_odd(5);
    prime(5);
    }

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top