SlideShare a Scribd company logo
1 of 7
Download to read offline
C# and Dot Net Framework
Prof. K. Adisesha 1
C# and Dot Net Framework
Part A
Steps to execute these programs
Step 1. Path Environment variable for C# Compiler
Copy the path of .NET framework from your computer
Copy the path: “C:WindowsMicrosoft.NETFramework64v4.0.30319”
Search for environment variable in Start menu
Double click on “Path” Variable
Click New
Paste the given path
Press Ok
Step 2. Running the C# program
Save the Program using .cs extension
Open command prompt
Using cd command go to the desired directory(folder)
Step 3. Compile the program using the following method:
“csc filename.cs”
Once compiled successfully corresponding .exe file created with same name as the
program name
Step 4. Run the program at command prompt using: “.filename.exe”
C# Lab Programs:
1.//Fibonacci series program in C#.
using System;
public class Fibonacci
{
public static void Main(string[] args)
{
int n1=0,n2=1,n3,i,number;
Console.Write("Enter the number of elements: ");
number = int.Parse(Console.ReadLine());
Console.Write(n1+" "+n2+" "); //printing 0 and 1
for(i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed
{
n3=n1+n2;
Console.Write(n3+" ");
n1=n2;
n2=n3;
}
}
}
Output:
Enter the number of elements: 15
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
C# and Dot Net Framework
Prof. K. Adisesha 2
2. Prime Number Program in C#
using System;
public class PrimeNumber
{
public static void Main(string[] args)
{
int n, i, m=0, flag=0;
Console.Write("Enter the Number to check Prime: ");
n = int.Parse(Console.ReadLine());
m=n/2;
for(i = 2; i <= m; i++)
{
if(n % i == 0)
{
Console.Write("Number is not Prime.");
flag=1;
break;
}
}
if (flag==0)
Console.Write("Number is Prime.");
}
}
Output:
Enter the Number to check Prime: 17
Number is Prime.
Enter the Number to check Prime: 57
Number is not Prime.
3. Palindrome program in C#
using System;
public class Palindrome
{
public static void Main(string[] args)
{
int n,r,sum=0,temp;
Console.Write("Enter the Number: ");
n = int.Parse(Console.ReadLine());
temp=n;
while(n>0)
{
r=n%10;
C# and Dot Net Framework
Prof. K. Adisesha 3
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
Console.Write("Number is Palindrome.");
else
Console.Write("Number is not Palindrome");
}
}
Output:
Enter the Number=121
Number is Palindrome.
Enter the number=113
Number is not Palindrome.
4. Factorial Program in C#:
using System;
public class Factorial
{
public static void Main(string[] args)
{
int i,fact=1,number;
Console.Write("Enter any Number: ");
number= int.Parse(Console.ReadLine());
for(i=1;i<=number;i++){
fact=fact*i;
}
Console.Write("Factorial of " +number+" is: "+fact);
}
}
Output:
Enter any Number: 6
Factorial of 6 is: 720
5. Sum of digits program in C#
using System;
public class Sumdigit
{
public static void Main(string[] args)
{
int n,sum=0,m;
C# and Dot Net Framework
Prof. K. Adisesha 4
Console.Write("Enter a number: ");
n= int.Parse(Console.ReadLine());
while(n>0)
{
m=n%10;
sum=sum+m;
n=n/10;
}
Console.Write("Sum is= "+sum);
}
}
Output:
Enter a number: 23
Sum is= 5
Enter a number: 624
Sum is= 12
6. C# Program to find the reverse of a number
using System;
public class ReverseDigit
{
public static void Main(string[] args)
{
int n, reverse=0, rem;
Console.Write("Enter a number: ");
n= int.Parse(Console.ReadLine());
while(n!=0)
{
rem=n%10;
reverse=reverse*10+rem;
n/=10;
}
Console.Write("Reversed Number: "+reverse);
}
}
Output:
Enter a number: 234
Reversed Number: 432
7. C# Program to swap two numbers without third variable
using System;
public class SwapNumber
C# and Dot Net Framework
Prof. K. Adisesha 5
{
public static void Main(string[] args)
{
int a=5, b=10;
Console.WriteLine("Before swap a= "+a+" b= "+b);
a=a+b; //a=15 (5+10)
b=a-b; //b=5 (15-10)
a=a-b; //a=10 (15-5)
Console.Write("After swap a= "+a+" b= "+b);
}
}
Output:
Before swap a= 5 b= 10
After swap a= 10 b= 5
8. //C# Program to Print Pascal Triangle
using System;
public class PascalTri
{
public static void Main(string[] args)
{
int i,j,k,l,n;
Console.Write("Enter the Range=");
n= int.Parse(Console.ReadLine());
for(i=1; i<=n; i++)
{
for(j=1; j<=n-i; j++)
{
Console.Write(" ");
}
for(k=1;k<=i;k++)
{
Console.Write(k);
}
for(l=i-1;l>=1;l--)
{
Console.Write(l);
}
Console.Write("n");
}
}
}
C# and Dot Net Framework
Prof. K. Adisesha 6
Output:
Enter the Range=5
1
121
12321
1234321
123454321
9. Program to demonstrate Multithreaded Programming in C#.NET
using System.Threading;
using System;
namespace ThreadingDemo
{
class ThreadProg
{
static void Main(string[] args)
{
Thread t = Thread.CurrentThread;
//By Default, the Thread does not have any name
//if you want then you can provide the name explicitly
t.Name = "Main Thread";
Console.WriteLine("Current Executing Thread Name :" + t.Name);
Console.WriteLine("Current Executing Thread Name :" + Thread.CurrentThread.Name);
Console.Read();
}
}
}
Output:
Current Executing Thread Name :Main Thread
Current Executing Thread Name :Main Thread
10. //Program to find square of a number using subroutines and functions in C#.NET
using System;
class SubProgram
{
// function with integer return type declaration
public int square(int nmbr)
{
int sq = nmbr * nmbr;
// Lets provide a return statement
return sq;
}
public static void Main(string[] args)
C# and Dot Net Framework
Prof. K. Adisesha 7
{
SubProgram pr = new SubProgram(); // Creating a class Object
Console.Write("Enter a number: ");
int n= int.Parse(Console.ReadLine());
int rslt = pr.square( n); //Calling the method and assigning the value to an integer type
Console.WriteLine("Square of the given number is "+ rslt); //Printing the result
}
}
Output
Square of the given number is 4
Part B
Based on VB.net

More Related Content

What's hot (20)

Introduction To C#
Introduction To C#Introduction To C#
Introduction To C#
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and Functions
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPREC
 
Array in c#
Array in c#Array in c#
Array in c#
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Python Basics
Python BasicsPython Basics
Python Basics
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
Chapter 2 c#
Chapter 2 c#Chapter 2 c#
Chapter 2 c#
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
C# - Part 1
C# - Part 1C# - Part 1
C# - Part 1
 
C# Basics
C# BasicsC# Basics
C# Basics
 

Similar to C# Dot Net Framework Guide

Similar to C# Dot Net Framework Guide (20)

Hems
HemsHems
Hems
 
C#.net
C#.netC#.net
C#.net
 
C# console applications.docx
C# console applications.docxC# console applications.docx
C# console applications.docx
 
1 c introduction
1 c introduction1 c introduction
1 c introduction
 
Net practicals lab mannual
Net practicals lab mannualNet practicals lab mannual
Net practicals lab mannual
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
C# 6Write a program that creates a Calculation ClassUse the foll.pdf
C# 6Write a program that creates a Calculation ClassUse the foll.pdfC# 6Write a program that creates a Calculation ClassUse the foll.pdf
C# 6Write a program that creates a Calculation ClassUse the foll.pdf
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
P2
P2P2
P2
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
C++ Certified Associate Programmer CPA
C++ Certified Associate Programmer CPAC++ Certified Associate Programmer CPA
C++ Certified Associate Programmer CPA
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
C#unit4
C#unit4C#unit4
C#unit4
 
C# p3
C# p3C# p3
C# p3
 
C Programming
C ProgrammingC Programming
C Programming
 

More from Prof. Dr. K. Adisesha

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfProf. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaProf. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfProf. Dr. K. Adisesha
 

More from Prof. Dr. K. Adisesha (20)

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 

Recently uploaded

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 

Recently uploaded (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 

C# Dot Net Framework Guide

  • 1. C# and Dot Net Framework Prof. K. Adisesha 1 C# and Dot Net Framework Part A Steps to execute these programs Step 1. Path Environment variable for C# Compiler Copy the path of .NET framework from your computer Copy the path: “C:WindowsMicrosoft.NETFramework64v4.0.30319” Search for environment variable in Start menu Double click on “Path” Variable Click New Paste the given path Press Ok Step 2. Running the C# program Save the Program using .cs extension Open command prompt Using cd command go to the desired directory(folder) Step 3. Compile the program using the following method: “csc filename.cs” Once compiled successfully corresponding .exe file created with same name as the program name Step 4. Run the program at command prompt using: “.filename.exe” C# Lab Programs: 1.//Fibonacci series program in C#. using System; public class Fibonacci { public static void Main(string[] args) { int n1=0,n2=1,n3,i,number; Console.Write("Enter the number of elements: "); number = int.Parse(Console.ReadLine()); Console.Write(n1+" "+n2+" "); //printing 0 and 1 for(i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed { n3=n1+n2; Console.Write(n3+" "); n1=n2; n2=n3; } } } Output: Enter the number of elements: 15 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
  • 2. C# and Dot Net Framework Prof. K. Adisesha 2 2. Prime Number Program in C# using System; public class PrimeNumber { public static void Main(string[] args) { int n, i, m=0, flag=0; Console.Write("Enter the Number to check Prime: "); n = int.Parse(Console.ReadLine()); m=n/2; for(i = 2; i <= m; i++) { if(n % i == 0) { Console.Write("Number is not Prime."); flag=1; break; } } if (flag==0) Console.Write("Number is Prime."); } } Output: Enter the Number to check Prime: 17 Number is Prime. Enter the Number to check Prime: 57 Number is not Prime. 3. Palindrome program in C# using System; public class Palindrome { public static void Main(string[] args) { int n,r,sum=0,temp; Console.Write("Enter the Number: "); n = int.Parse(Console.ReadLine()); temp=n; while(n>0) { r=n%10;
  • 3. C# and Dot Net Framework Prof. K. Adisesha 3 sum=(sum*10)+r; n=n/10; } if(temp==sum) Console.Write("Number is Palindrome."); else Console.Write("Number is not Palindrome"); } } Output: Enter the Number=121 Number is Palindrome. Enter the number=113 Number is not Palindrome. 4. Factorial Program in C#: using System; public class Factorial { public static void Main(string[] args) { int i,fact=1,number; Console.Write("Enter any Number: "); number= int.Parse(Console.ReadLine()); for(i=1;i<=number;i++){ fact=fact*i; } Console.Write("Factorial of " +number+" is: "+fact); } } Output: Enter any Number: 6 Factorial of 6 is: 720 5. Sum of digits program in C# using System; public class Sumdigit { public static void Main(string[] args) { int n,sum=0,m;
  • 4. C# and Dot Net Framework Prof. K. Adisesha 4 Console.Write("Enter a number: "); n= int.Parse(Console.ReadLine()); while(n>0) { m=n%10; sum=sum+m; n=n/10; } Console.Write("Sum is= "+sum); } } Output: Enter a number: 23 Sum is= 5 Enter a number: 624 Sum is= 12 6. C# Program to find the reverse of a number using System; public class ReverseDigit { public static void Main(string[] args) { int n, reverse=0, rem; Console.Write("Enter a number: "); n= int.Parse(Console.ReadLine()); while(n!=0) { rem=n%10; reverse=reverse*10+rem; n/=10; } Console.Write("Reversed Number: "+reverse); } } Output: Enter a number: 234 Reversed Number: 432 7. C# Program to swap two numbers without third variable using System; public class SwapNumber
  • 5. C# and Dot Net Framework Prof. K. Adisesha 5 { public static void Main(string[] args) { int a=5, b=10; Console.WriteLine("Before swap a= "+a+" b= "+b); a=a+b; //a=15 (5+10) b=a-b; //b=5 (15-10) a=a-b; //a=10 (15-5) Console.Write("After swap a= "+a+" b= "+b); } } Output: Before swap a= 5 b= 10 After swap a= 10 b= 5 8. //C# Program to Print Pascal Triangle using System; public class PascalTri { public static void Main(string[] args) { int i,j,k,l,n; Console.Write("Enter the Range="); n= int.Parse(Console.ReadLine()); for(i=1; i<=n; i++) { for(j=1; j<=n-i; j++) { Console.Write(" "); } for(k=1;k<=i;k++) { Console.Write(k); } for(l=i-1;l>=1;l--) { Console.Write(l); } Console.Write("n"); } } }
  • 6. C# and Dot Net Framework Prof. K. Adisesha 6 Output: Enter the Range=5 1 121 12321 1234321 123454321 9. Program to demonstrate Multithreaded Programming in C#.NET using System.Threading; using System; namespace ThreadingDemo { class ThreadProg { static void Main(string[] args) { Thread t = Thread.CurrentThread; //By Default, the Thread does not have any name //if you want then you can provide the name explicitly t.Name = "Main Thread"; Console.WriteLine("Current Executing Thread Name :" + t.Name); Console.WriteLine("Current Executing Thread Name :" + Thread.CurrentThread.Name); Console.Read(); } } } Output: Current Executing Thread Name :Main Thread Current Executing Thread Name :Main Thread 10. //Program to find square of a number using subroutines and functions in C#.NET using System; class SubProgram { // function with integer return type declaration public int square(int nmbr) { int sq = nmbr * nmbr; // Lets provide a return statement return sq; } public static void Main(string[] args)
  • 7. C# and Dot Net Framework Prof. K. Adisesha 7 { SubProgram pr = new SubProgram(); // Creating a class Object Console.Write("Enter a number: "); int n= int.Parse(Console.ReadLine()); int rslt = pr.square( n); //Calling the method and assigning the value to an integer type Console.WriteLine("Square of the given number is "+ rslt); //Printing the result } } Output Square of the given number is 4 Part B Based on VB.net