using System;
namespace st
{
class StrongNumber
{
public static void Main(string[] args)
{
int num = Int32.Parse(args[0]);
int orgnum = num;
int total = 0;
while (num != 0)
{
// take a digit
int digit = num % 10;
int factorial = 1;
for (int i = 1; i <= digit; i++)
factorial *= i;
total += factorial;
// remove digit
num /= 10;
}
if (total == orgnum)
Console.WriteLine("{0} is a strong number", orgnum);
else
Console.WriteLine("{0} is not a strong number", orgnum);
} // main
} // class
} // st
Write a program to calculate the total expenses. Quantity and price per item are input by the user and discount of 10% is offered if the expense is more than 7000.
#include<iostream.h> #include<conio.h> void main() { int totalexp, qty, price, discount; cout<<" Enter quantity: "; cin>>qty; cout<<" Enter price: "; cin>>price; totalexp=qty*price; if (totalexp>7000) { discount=(totalexp*0.1); totalexp=totalexp-discount; } cout<<" Total Expense is Rs. "<<totalexp; getch(); }
Comments
Post a Comment