Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
18 views2 pages

Lab Pointer

The document contains several C++ code snippets that demonstrate different programming concepts such as pointer usage, input/output operations, and mathematical calculations. Each code segment prompts the user for input and performs operations based on the input values, including checking divisibility, calculating results based on conditions, and computing distances between points. The snippets illustrate various programming techniques and logical structures in C++.

Uploaded by

vlad prangati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Lab Pointer

The document contains several C++ code snippets that demonstrate different programming concepts such as pointer usage, input/output operations, and mathematical calculations. Each code segment prompts the user for input and performs operations based on the input values, including checking divisibility, calculating results based on conditions, and computing distances between points. The snippets illustrate various programming techniques and logical structures in C++.

Uploaded by

vlad prangati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

3.

#include <iostream>

using namespace std;

int main()
{int a,b,c;
cout<<"Introduceti a,b si c"<<endl;
cin>>a>>b>>c;
int* ptr1=&a;
int* ptr2=&b;
int* ptr3=&c;
int n;
cout<<"Introduceti N"<<endl;
cin>>n;
if(*ptr1%n==0&&*ptr2%n==0&&*ptr3==0) cout<<"Toate sunt divizibile";
if(*ptr1%n==0) cout<<"a este divizibil";
if(*ptr2%n==0) cout<<"b este divizibil";
if(*ptr3%n==0) cout<<"c este divizibil";
else cout<<"Nicio variabila nu este divizibila";

return 0;
}
1.
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
double n=7.3;
double y,b;
double x;
double *ptr1=&y;
double *ptr2=&b;
double *ptr3=&x;
cout<<"Introduceti valoarea lui b si x"<<endl;
cin>>b>>x;
if(*ptr3<2) *ptr1=*ptr2*(3*pow(*ptr3,2)+n)/5;
else if (2<=*ptr3<=3) *ptr1=*ptr2-abs(pow(*ptr3,2)-4**ptr3+6);
else if (*ptr3>3) *ptr1=(*ptr2**ptr3)+sin(*ptr3);
cout<<"Rezultatul este "<<*ptr1;
return 0;
}

5.

#include <iostream>
using namespace std;

int main() {
int arr[100000], num;
int* ptr=arr;
cout << "Introduceti numarul de elemente: ";
cin >> num;
for (int x = 1; x<= num; x++) {
cout << "Introduceti elementele: "<<endl;
cin >> ptr[num];}
for (int x = num - 1; x>= 0; -- x) {
cout << ptr[num]<< endl;
ptr[num] -= 1;
}}
8.
#include<iostream>

using namespace std;

int main()

{int c,i=0,j=1,nr,p=1,n;
int* ptr1=&c;
int* ptr2=&j;
int* ptr3=&nr;
int* ptr4=&p;
int* ptr5=&n;
int* ptr6=&i;
cin>>c>>n;
while(*ptr2<=*ptr5)
{
cin>>nr;
if(*ptr3<*ptr1)
i++;
else *ptr4=*ptr4**ptr5;
j++;
}
cout<<endl<<*ptr6<<endl<<*ptr4;
return 0;}
2.
#include <iostream>
#include <cmath>
using namespace std;

int main ()
{
double d,x1,x2,y1,y2;
double *ptr1=&d;
double *ptr2=&x1;
double *ptr3=&x2;
double *ptr4=&y1;
double ptr5=&y2;
cout<<"Introduceti datele"<<endl;
cin>>ptr2>>ptr3>>ptr4>>*ptr5;
ptr1=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
cout<<"Distanta dintre aceste puncte este: "<<ptr1;
}

You might also like