Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.
- #include <iostream.h>
- #include <conio.h>
- int main()
- {int a,b,c,r,s,x;
- cout<<"Introdu deimpartitorul:";cin>>a;
- cout<<"Intordu impartitorul:";cin>>b;
- c=0;r=0;s=0;
- while(a>0)
- {
- if(a>b)
- {
- s=a-b;
- c+=1;
- }
- else if(a<b)
- {
- r=a;
- }
- x=a-b;
- a=a-b;
- }
- cout<<"Catul:"<<c<<"\n Rest"<<r;
- getch();
- }
- 2.
- #include<iostream.h>
- #include<conio.h>
- int main()
- {int a,b,c,r;
- c=0;r=0;
- cout<<"Introdu numarul:";cin>>a;
- cout<<"Introdu exponentul:";cin>>b;
- do
- {
- r=a*a;
- c+=1;
- }while(c!=b);
- cout<<r;
- getch();
- }
- 3.
- #include <iostream.h>
- #include <conio.h>
- int main()
- {int a,b,c;
- cout<<"Introdu numarul dorit:";cin>>a;
- c=0;
- b=2;
- cout<<"Divizorii numarului "<<a<<" sunt:\n";
- while(b!=a)
- {
- if(a%b==0)
- {
- c=a/b;
- cout<<"\t\t";cout<<c;cout<<"\n";
- b++;
- }
- else
- {
- b++;
- }
- }
- getch();
- cout<<"Mai incearca si alte numere:";cin>>a;
- }
- 4.
- #include <iostream.h>
- #include <conio.h>
- int main()
- {int a,p,s;
- p=1;
- s=0;
- do
- {
- cout<<"\n\nNumarul:";cin>>a;
- if(a==0)
- {
- cout<<"Introdu valori pozitive";
- }
- else
- {
- if(a%2==0)
- p=p*a;
- else if(a%3>0)
- s+=a;
- cout<<"\nProdusul nr. pare:"<<p;
- cout<<"\nSuma nr. impare:"<<s;
- }
- }while(a != 0);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement