Asterik Program
Asterik Program
Asterik Program
777-FOC/BSIT/F22 B
PROGRAMMING FUNDAMENTAL
ASTERIK PROGRAM
#include <iostream>
using namespace std;
int main()
{
int i,j,k;
for (int i = 1; i <=3 ; i++)
{
for (int j = 3-i; j >= 0; j--)
cout << " ";
for (int k = 1;k <= i;k++)
cout << "*";
cout << endl;
}
return 0;
}
SWITCH PROGRAM
#include<iostream>
using namespace std;
int main()
{
int option = 0;
int choice=0;
while (choice != -1)
{
cout<<"\nEnterchoice\n1:Add\n2:Subtract\n3:Multiple";
cin >> option;
int a = 27; int b = 3;
switch (option)
{
case 1:cout << "\nAdd\n"
<< a << '+' << b << '='
<< a + b << endl;
break;
case 2:cout << "\nSubtract\n"
<< a << '-' << b
<< '=' << a - b << endl;
break;
case 3:cout << "\nMultiply\n"
<< a << '*' << b
<< '=' << a * b << endl;
break;
default:cout << "\n\aWrong option\n\a";
break;
}//end switch
cout << "Do you want to continue?";
cin >> choice;
}
system ("pause");
return 0;
}
ZAKAT CALCULATOR
#include<iostream>
using namespace std;
int main()
{
float gold = 0, silver = 0, assests = 0,cash=0;
float monetary_gold = 7.5;
float monetary_silver = 52.5;
float goldrate = 204700, silverrate = 2386;
float totalgold=0, totalsilver=0;
float zakat, total;
cout << "\nEnter the value of gold in tolas:";
cin >> gold;
cout << "\nEnter the value of silver in tolas:";
cin >> silver;
cout << "\nEnter the value of assests:";
cin >> assests;
cout << "Enter the value of cash:";
cin >> cash;
while (gold!= -1)
{
if (gold >=monetary_gold)
totalgold = gold * goldrate;
if (silver >= monetary_silver)
totalsilver = silver * silverrate;
total = totalgold + totalsilver;
zakat = total / 2.5 * 100;
cout << "Zakat:" << zakat;
cout << endl;
cout << "\nEnter the value of gold in tolas:";
cin >> gold;
cout << "\nEnter the value of silver in tolas:";
cin >> silver;
cout << "\nEnter the value of assests:";
cin >> assests;
cout << "Enter the value of cash:";
cin >> cash;
}
system("pause");
return 0;
}