تمرین مقدمات برنامه نویسی
سوال
. برنامه ای نوشته و اجرا کنید که مجموع، تفاضل، حاصل ضرب، خارج قسمت و باقیمانده دو عدد ۶۰ و ۷ را چاپ کند.
. برنامه ای نوشته و اجرا کنید که دو عدد صحیح از ورودی گرفته و مجموع، تفاضل، حاصلضرب، خارج قسمت و باقیمانده آن دو عدد را چاپ کند.
در حال بررسی
1
انجمن برنامه نویسان ++C
2 سال
2 پاسخ ها
200 دیده شده
0
پاسخ ها ( ۲ )
#include
using namespace std;
int main()
{
int x;
int y;
int answer;
cout <> x ;
cout <> y ;
//total
answer = x+y ;
cout<< "n the total: "<< answer ;
//submission
answer = x-y ;
cout<< "n the submission: "<< answer ;
//multiplication
answer = x*y ;
cout<< "n the multiplication: "<< answer ;
//division
answer = x/y ;
cout<< "n the division: "<< answer ;
//left over
answer = x%y ;
cout<< "n the left over: "<< answer ;
}
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int x,y;
cout<<“Enter 2 number : “<<endl;
cin>>x>>y;
float sum=x+y;
cout<<“Sum is : “<<sum<<endl;
float sub=fabs(x-y);
cout<<“Sub is : “<<sub<<endl;
float mul=x*y;
cout<<“Mul is : “<<mul<<endl;
if(x>y)
{
int b=x%y;
cout<<“The remaining number : “<<b<<endl;
}
else
{
int b=y%x;
cout<<“The remaining number : “<<b<<endl;
if(b==0)
cout<<“Is divisible.”<<endl;
else
cout<<“Not divisible.”;
}
}