0% found this document useful (0 votes)
20 views

Awp New

The document contains code snippets for 4 programs: 1) A program to reverse a number and find the sum of its digits. 2) A program to calculate the factorial of a number. 3) A program to perform currency conversion between dollars, euros and Malaysian ringgit to rupees. 4) A program to perform temperature conversion between Celsius and Fahrenheit. For each program, the code is provided along with sample input/output.

Uploaded by

PARADIGM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Awp New

The document contains code snippets for 4 programs: 1) A program to reverse a number and find the sum of its digits. 2) A program to calculate the factorial of a number. 3) A program to perform currency conversion between dollars, euros and Malaysian ringgit to rupees. 4) A program to perform temperature conversion between Celsius and Fahrenheit. For each program, the code is provided along with sample input/output.

Uploaded by

PARADIGM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DATE: 15-07-2023 Advanced Web Programming Semester- V

T.Y.B.SC.I.T IT21063

V) Create an application to reverse a number and find sum of digits


of a number.
Code:
using System;
using System.Collections;
namespace VSCODES
{
class Program
{
static void Main(string[] args)
{
int i,rem,rev=0,sum=0;
Console.WriteLine("Enter a number:");
n=Convert.ToInt32(Console.ReadLine());
while(n!=0)
{
rem=n%10;

sum=sum+rem;
n/=10;
rev=rev*10+rem;
}
Console.WriteLine("Sum of digits:"+sum);
Console.WriteLine("Reverse of number:"+rev);
}
}
}
DATE: 15-07-2023 Advanced Web Programming Semester- V
T.Y.B.SC.I.T IT21063

OUTPUT :
DATE: 15-07-2023 Advanced Web Programming Semester- V
T.Y.B.SC.I.T IT21063

Practical 2A
i) Create a simple application for finding factorial value.
Code:
using System;
using System.Collections;
namespace VSCODES {
class Program {
static void Main(string[] args)

{
int i,fact=1,n;
Console.WriteLine("Enter a number:");
n=Convert.ToInt32(Console.ReadLine());
for(i=1;i<=n;i++) {
fact= fact*i;
}
Console.WriteLine("Factorial of:"+fact);
}
}

OUTPUT :
DATE: 15-07-2023 Advanced Web Programming Semester- V
T.Y.B.SC.I.T IT21063

ii) Create a simple application to perform Money Conversion.


CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace VSCODES
{
class Program
{
static void Main(string[] args)
{
int choice;
Console.WriteLine("Enter your Choice :\n 1- Dollar to Rupee \n 2 - Euro to Rupee \n 3
- Malaysian Ringgit to Rupee ");
choice = int.Parse(Console.ReadLine());

switch (choice)
{
case 1:
Double dollar, rupee, val=82.09;
Console.WriteLine("Enter the Dollar Amount :");
dollar = Double.Parse(Console.ReadLine());
rupee = dollar * val;
Console.WriteLine("{0} Dollar Equals {1} Rupees", dollar, rupee);
break;
case 2:
Double Euro, rupe, valu=92.32;
DATE: 15-07-2023 Advanced Web Programming Semester- V
T.Y.B.SC.I.T IT21063
Console.WriteLine("Enter the Euro Amount :");
Euro = Double.Parse(Console.ReadLine());
rupe = Euro * valu;
Console.WriteLine("{0} Euro Equals {1} Rupees", Euro, rupe);
break;
case 3:
Double baht, rup, value=2.73;
Console.WriteLine("Enter the baht Amount :");
baht = Double.Parse(Console.ReadLine());
rup = baht * value;
Console.WriteLine("{0} Thiland baht Equals {1} Rupees", baht, rup);
break;
}
Console.ReadLine();
}
}
}

OUTPUT :
DATE: 15-07-2023 Advanced Web Programming Semester- V
T.Y.B.SC.I.T IT21063

iv) Create a simple application to perform Temperature Conversion.


CODE :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace VSCODES
{
class Program
{
static void Main(string[] args)
{
int choice;
Console.Write
("Enter your choice of conversion:\n1) Celsius to Fahrenheit or 2) Fahrenheit to
Celsius\nYour choice = ");

choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
Console.WriteLine("Enter temperature in Celsius: ");
double celsius = double.Parse(Console.ReadLine());

double fahrenheit = (celsius * 9) / 5 + 32;


Console.WriteLine("Temperature in Fahrenheit: " + fahrenheit);
break;
case 2:
DATE: 15-07-2023 Advanced Web Programming Semester- V
T.Y.B.SC.I.T IT21063
Console.WriteLine("Enter temperature in fahrenheit: ");
double f = double.Parse(Console.ReadLine());
double celsi = (f - 32) / 1.8;
Console.WriteLine("Temperature in Celsius: " + celsi);
break;

}
Console.ReadLine();
}
}
}

OUTPUT :

You might also like