0% found this document useful (0 votes)
20 views

Scripd

The document contains examples of C++ programs that demonstrate the use of conditional statements like if-else. The programs check for conditions on input values, compare numbers and strings, and output corresponding results.

Uploaded by

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

Scripd

The document contains examples of C++ programs that demonstrate the use of conditional statements like if-else. The programs check for conditions on input values, compare numbers and strings, and output corresponding results.

Uploaded by

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

Tema pe acasa

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

double fx, x;

cout << "Introduceti valorea lui x:";

cin>>x;

fx=pow(x,3)+pow(x,2); cout << " 1: F(x)="<<setprecision(3)<<fx<<endl;

fx=1/x+1/pow(x,2); cout << " 2: F(x)="<<setprecision(3)<<fx<<endl;

fx=fabs(x)/(pow(x,2)+1); cout << " 3: F(x)="<<setprecision(3)<<fx<<endl;

fx=pow(x,2)*log(x); cout << " 4: F(x)="<<setprecision(3)<<fx<<endl;

fx=sin(x)+1/2*sin(2*x); cout << " 5: F(x)="<<setprecision(3)<<fx<<endl;

fx=pow(x,2)+8/x; cout << " 6: F(x)="<<setprecision(3)<<fx<<endl;

fx=pow(M_E,pow(-x,2)); cout << " 7: F(x)="<<setprecision(3)<<fx<<endl;

fx=(pow(M_E,x)-pow(M_E,-x))/2; cout << " 8: F(x)="<<setprecision(3)<<fx<<endl;

fx=(pow(M_E,x)-pow(M_E,-x))/(pow(M_E,x)+pow(M_E,-x)); cout << " 9:


F(x)="<<setprecision(3)<<fx<<endl;

fx=tan(x)/x; cout << "10: F(x)="<<setprecision(3)<<fx<<endl;

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

double fxy, x,y;


cout << "Introduceti valorea lui x:";cin>>x;

cout << "Introduceti valorea lui y:";cin>>y;

fxy=(pow(x,y)+pow(y,x))/(pow(x,-y)+pow(y,-x)); cout << " 1:


F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=(tan(x)+tan(y))/sqrt(fabs(x-y)+1); cout << " 2:


F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=fabs(x-y)/(x+sin(M_PI/y))*cos(M_PI/x); cout << " 3:


F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=sqrt(fabs(x-y)/sqrt(1/fabs(x-y))*(fabs(x)+1)); cout << " 4:


F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=(sin(x)+sin(y))/(pow(M_E,y)+pow(M_E,x)); cout << " 5:


F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=pow(y,1/x)+pow(x,1/y); cout << " 6: F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=((x-y)/sqrt(x+y))+1+(pow(x,2)-pow(y,2)/pow(x,2)+pow(y,2)+1);cout << " 7:


F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=pow(cos(x),2)+2*pow(sin(y),2)/M_PI; cout << " 8:


F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=(x+y)/sqrt((pow(x,2)+pow(y,2)+1)*pow(sin(x+y),2)); cout << " 9:


F(x,y)="<<setprecision(4)<<fxy<<endl;

fxy=(log(x)+log(y))/(pow(M_E,y)+pow(M_E,-x)); cout << "10:


F(x,y)="<<setprecision(4)<<fxy<<endl;

return 0;

}
#include <iostream>

using namespace std;

int main()

int a, b; cout<<"Introduceti punctajele="<<endl;

cout<<"primul "; cin>>a;

cout<<"al doilea "; cin>>b;

if (a>b) cout<<a<<" puncte "<<b<<" puncte ";

else cout<<b<<" puncte "<<a<<" puncte ";

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a, b;

cout<<"Introduceti doua numere:"; cin>>a>>b;

if (a>b) {a=a*2; b=b*3; cout<<a<<setw(3)<<b;}

else {b=b*2; a=a*3; cout<<a<<setw(3)<<b;}

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a, b;

cout<<"Introduceti doua numere:"; cin>>a>>b;

if (b==a+1) cout<<"Da";

else cout<<"Nu";

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a, b, c;

cout<<"Introduceti 3 numere:"; cin>>a>>b>>c;

if (a>=7) cout<<a<<endl;

if (b>=7) cout<<b<<endl;

if (c>=7) cout<<c<<endl;

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

double a, b,c;

cout<<"Introduceti 2 numere:"; cin>>a>>b;

if (b==0) {cout<<"Impartire imposibila";}

else {c=a/b; cout<<"Catul este="<<setprecision(3)<<c;}

return 0;

#include<iostream>

#include <iomanip>

#include <math.h>
using namespace std;

int main()

double a, b,c=100;

cout<<"Introduceti greutatea copiilor: "; cin>>a>>b;

if ((a+b)<=c) {cout<<"POT INTRA AMBII COPII";}

else {cout<<"INTRA PE RIND";}

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;


int main()

double a, b, c, d, e, f, g;

cout<<"Introduceti nr de ore: "; cin>>a>>b>>c>>d>>e>>f>>g;

if ((a+b+c+d+e+f+g)<=20) {cout<<"Nu va fi pedepsit";}

else {cout<<"Va fi pedepsit";}

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

double M, F , inaltime, varsta;


char s;

cout<<"Introduceti inaltimea persoanei "; cin>>inaltime;

cout<<"Introduceti varsta persoanei "; cin>>varsta;

cout<<"Introduceti sexul persoanei "; cin>>s;

M=50+0.75*(inaltime-150)+(varsta-20)/4;

F=M-10;

if (s=='M'){cout<<"Greutate="<<M<<"kg";}

else if (s=='F'){cout<<"Greutate="<<F<<"kg";}

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a, b, c;

string s;

cout<<"Introduceti 3 numere:"; cin>>a>>b>>c;

if (a%2==0) cout<<a<<" Par"<<endl;


else cout<<a<<" Impar"<<endl;

if (b%2==0) cout<<b<<" Par"<<endl;

else cout<<b<<" Impar"<<endl;

if (c%2==0) cout<<c<<" Par"<<endl;

else cout<<c<<" Impar"<<endl;

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int n, m;

cout<<"Introduceti n="; cin>>n;

m=n/4;

cout<<"Casuta "<<m;

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int x;

cout<<"Introduceti x="; cin>>x;

if (1<=x && x<=25) cout<<"A";

else if (26<=x && x<=50) cout<<"B";

else if (51<=x && x<=75) cout<<"C";

else if (76<=x && x<=100) cout<<"D";

else if (101<=x && x<=125) cout<<"E";

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a,b,c;

cout<<"Introduceti 3 numere= "; cin>>a>>b>>c;

if (a>b && b>c) {cout<<"Max="<<a<<" Min="<<c;}

else if(a>c && c>b) {cout<<"Max="<<a<<" Min="<<b;}

else if(b>a && a>c) {cout<<"Max="<<b<<" Min="<<c;}

else if(b>c && c>a) {cout<<"Max="<<b<<" Min="<<a;}

else if(c>a && a>b) {cout<<"Max="<<c<<" Min="<<b;}

else if(c>b && b>a) {cout<<"Max="<<c<<" Min="<<a;}

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a,b,c;

cout<<"Introduceti 3 numere= "; cin>>a>>b>>c;

if (a>b && b>c) {cout<<a<<setw(3)<<b<<setw(3)<<c;}

else if(a>c && c>b) {cout<<a<<setw(3)<<c<<setw(3)<<b;}

else if(b>a && a>c) {cout<<b<<setw(3)<<a<<setw(3)<<c;}

else if(b>c && c>a) {cout<<b<< setw(3)<<c<<setw(3)<<a;}

else if(c>a && a>b) {cout<<c<<setw(3)<<a<<setw(3)<<b;}

else if(c>b && b>a) {cout<<c<<setw(3)<<b<<setw(3)<<a;}

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a,b,c;

cout<<"Introduceti 3 numere= "; cin>>a>>b>>c;

if (a>b && b>c) {cout<<b;}

else if(a>c && c>b) {cout<<c;}

else if(b>a && a>c) {cout<<a;}

else if(b>c && c>a) {cout<<c;}

else if(c>a && a>b) {cout<<a;}

else if(c>b && b>a) {cout<<b;}

return 0;

}
#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a,b,c;

cout<<"Introduceti 3 numere= "; cin>>a>>b>>c;

if (b==a+1 && c==b+1) cout<<"Da";

else cout<<"Nu";

return 0;

#include <iostream>

#include <iomanip>
#include <math.h>

using namespace std;

int main()

int a,b,c;

cout<<"Introduceti notele= "; cin>>a>>b>>c;

if (c>7) cout<<a<<setw(2)<<b<<setw(2)<<c;

else if(a>b) cout<<a;

else cout<<b;

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;


int main()

int a,b,c;

cout<<"Introduceti 3 numere= "; cin>>a>>b>>c;

if (a%2==0 && b%2==0 && c%2==0) {if (b>c) cout<<b;

else cout<<c;}

else cout<<a+b;

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a,b;
cout<<"Introduceti 2 numere= "; cin>>a>>b;

if (a>b && a%2==0) cout<<a;

else if (b%2==0) cout<<b;

else cout<<"Nu exista numar par";

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a,b,c;

cout<<"Introduceti 3 numere= "; cin>>a>>b>>c;

if (a>b && b>c) {cout<<a<<b<<c;}

else if(a>c && c>b) {cout<<a<<c<<b;}


else if(b>a && a>c) {cout<<b<<a<<c;}

else if(b>c && c>a) {cout<<b<<c<<a;}

else if(c>a && a>b) {cout<<c<<a<<b;}

else if(c>b && b>a) {cout<<c<<b<<a;}

return 0;

#include <iostream>

#include <iomanip>

#include <math.h>

using namespace std;

int main()

int a,b,c;

cout<<"Introduceti 3 numere= "; cin>>a>>b>>c;

if (a>b && b>c && a!=0) {cout<<a<<b<<c;}

else if(a>c && c>b && a!=0) {cout<<a<<c<<b;}

else if(b>a && a>c && b!=0) {cout<<b<<a<<c;}

else if(b>c && c>a && b!=0) {cout<<b<<c<<a;}


else if(c>a && a>b && c!=0) {cout<<c<<a<<b;}

else if(c>b && b>a && c!=0) {cout<<c<<b<<a;}

return 0;

You might also like