0% found this document useful (0 votes)
9 views6 pages

P 5 PDF

programe C++

Uploaded by

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

P 5 PDF

programe C++

Uploaded by

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

/*

#include <iostream>

using namespace std;

int n,i,j;

int main()

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

for(i=1;i<=n;i++)

for(j=i;j>=1;j--)

cout<<j<<" ";

return 0;

*/

/*

// Sa se verifice daca un nr n este prim.

#include <iostream>

using namespace std;

int n,i,ok;

int main()

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

ok=1;

for(i=2;i<=n/2;i++)
if(n%i==0) ok=0;

if(ok==1) cout<<"este nr prim";

else cout<<"nu este nr prim";

return 0;

*/

/*

// Sa se afiseze cifrele unui nr n.

#include <iostream>

using namespace std;

int n,i,c;

int main()

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

while(n!=0)

{ c=n%10;

cout<<c<<" ";

n=n/10;

return 0;

*/

/*
//Sa se afiseze divizorii unui nr n.

#include <iostream>

using namespace std;

int n,i;

int main()

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

for(i=2;i<=n/2;i++)

if(n%i==0)

cout<<i<<" ";

return 0;

*/

/*

//Sa se afiseze de cate ori apare o cifra x in scierea unui nr n dat.

#include <iostream>

using namespace std;

int n,c,x,i;

int main()

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

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

while(n!=0)
{ c=n%10;

if(c==x) i++;

n=n/10;

cout<<i<<" ";

return 0;

*/

/*

//Sa se afiseze nr pare din intervalul [a,b]

#include <iostream>

using namespace std;

int a,b,i;

int main()

{ cout<<"a=";cin>>a;

cout<<"b=";cin>>b;

for(i=a;i<=b;i++)

if(i%2==0)

cout<<i<<" ";

return 0;

*/

/*
// Sa se calculeze suma cifrelor pare.

#include <iostream>

using namespace std;

int n,c,s=0;

int main()

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

while(n!=0)

{ c=n%10;

n=n/10;

if(c%2==0) s=s+c;

cout<<s<<" ";

return 0;

*/

/*

//Sa se afiseze nr din intervalul a,b care au suma cifrelor nr par.

#include <iostream>

using namespace std;

int a,b,s=0,c,n,i;

int main()

{ cout<<"a=";cin>>a;

cout<<"b=";cin>>b;
for(i=a;i<=b;i++)

{ n=i; s=0;

while(n!=0)

{ c=n%10;

s=s+c;

n=n/10;

if(s%2==0)

cout<<i<<" ";

*/

You might also like