Write C# Program to calculate the total marks,
percentage and division of student based on three
subjects
using System;
using [Link];
using [Link];
using [Link];
public class csharpExercise
static void Main(string[] args)
double rl, phy, che, ca, total;
double per;
string nm, div;
[Link]("\n\n");
[Link]("Calculate the total, percentage and division
to take marks of three subjects:\n");
[Link]("----------------------------------------------------------------------
---------");
[Link]("\n\n");
[Link]("Input the Roll Number of the student :");
rl = Convert.ToInt32([Link]());
[Link]("Input the Name of the Student :");
nm = [Link]();
[Link]("Input the marks of Physics : ");
phy = Convert.ToInt32([Link]());
[Link]("Input the marks of Chemistry : ");
che = Convert.ToInt32([Link]());
[Link]("Input the marks of Computer Application : ");
ca = Convert.ToInt32([Link]());
total = phy + che + ca;
per = total / 3.0;
if (per >= 60)
div = "First";
else
if (per < 60 && per >= 48)
div = "Second";
else
if (per < 48 && per >= 36)
div = "Pass";
else
div = "Fail";
[Link]("\nRoll No : {0}\nName of Student : {1}\n", rl,
nm);
[Link]("Marks in Physics : {0}\nMarks in Chemistry :
{1}\nMarks in Computer Application : {2}\n", phy, che, ca);
[Link]("Total Marks = {0}\nPercentage = {1}\
nDivision = {2}\n", total, per, div);
[Link]();
Write C# program to print day
of week name using switch
case
using System;
public class csharpExercise
static void Main(string[] args)
int weeknumber;
//Reading week no from user
[Link]("Enter week number(1-7): ");
weeknumber = Convert.ToInt32([Link]());
switch (weeknumber)
case 1: [Link]("Monday");
break;
case 2: [Link]("Tuesday");
break;
case 3: [Link]("Wednesday");
break;
case 4: [Link]("Thursday");
break;
case 5: [Link]("Friday");
break;
case 6: [Link]("Saturday");
break;
case 7: [Link]("Sunday");
break;
default:
[Link]("Invalid input! Please enter week no.
between 1-7.");
break;
[Link]();
Write a C# program to count a
total number of alphabets,
digits and special characters in
a string
using System;
public class StringExercise
public static void Main()
string str;
int alphabet, digit, specialchar, i, l;
alphabet = digit = specialchar = i = 0;
[Link]("Enter the string : ");
str = [Link]();
l = [Link];
while (i < l)
if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i]
<= 'Z'))
alphabet++;
else if (str[i] >= '0' && str[i] <= '9')
digit++;
else
specialchar++;
i++;
}
[Link]("Number of Alphabets in the string is : {0}\n",
alphabet);
[Link]("Number of Digits in the string is : {0}\n",
digit);
[Link]("Number of Special characters in the string is :
{0}\n\n", specialchar);
[Link]();