Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.

Paste

Pasted as C++ by registered user xujiayu ( 4 years ago )
#include <stdio.h>
#include <conio.h>

float xulytinhtoan (int a , int b , char pheptoan)
{
	if(pheptoan == '+')
	{
	   return a + b;
	}
	if(pheptoan == '-')
	{
	   return a - b;
	}
	if (pheptoan == '*')
	{
	   return a*b;
	}
	else
	{
		return (float) a / b ;
	}


}
int main()
	// cach goi ham dang 2 
{     
	int a = 1;
	 int b = 2;

	  int tong = xulytinhtoan (a, b , '+');
	  int hieu  = xulytinhtoan (a, b , '-');
	  int tich = xulytinhtoan (a, b , '*');
	  float thuong = xulytinhtoan (a, b , '/');
	  printf("\n%d",tong);
	  printf("\n%d",hieu);
	  printf("\n%d",tich);
	  printf("\n%f",thuong);
	
	getch();
	return 0;



}

 

Revise this Paste

Your Name: Code Language: