Sunteți pe pagina 1din 2

Assignment 1

Q1

Coding:

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
int num,one,two,three,four,temp;
cout<< " enter a four digit number";
cin>> num;

temp = num/1000;
one = temp;
temp = num % 1000;
two = temp/ 100;
temp = temp % 100;
three = temp /10;
temp =temp % 10;
four = temp % 1000;

cout<< one<< endl<< two<< endl<< three<< endl<< four << endl;

return 0;
}
Q2:

Coding:

#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float milk,carton,cost,profit;
cout<<"enter total amount of milk produced"; cin>>milk;
carton = milk/3.78;

cost = milk*0.38;
profit = floor(carton) * 0.27;

cout<<"total carton = "<<floor(carton)<<endl<<"total cost =


"<<cost<<endl<<"total profit = "<<profit<<endl;
return 0;
}

S-ar putea să vă placă și