Académique Documents
Professionnel Documents
Culture Documents
YOGESH
06315104411
ACKNOWLEDGEMENT
I wish to thanks all the people who have directly or indirectly contributed towards the successful completion of this work. First and Foremost, I wish to acknowledge the valuable guidance . I received from my teachers especially Mrs. Deepa Gangwani for his valuable suggestions and all time guidance during my lab duration and outside or inside the class. I am also thankful from the core of my heart to my fellow classmates and friends, who have assisted me in creating and completing this project without which it would have very difficult for me to accomplish the assigned task.
2
INDEX
S. No
1. 2. 3. 4. 5.
PROGRAMS
W.A.P to print C# Programming on screen. W.A.P to add two numbers. W.A.P of Fibonacci series W.A.P to find even and odd number. W.A.P to add marks of student in five subjects and display their his/her details in the following format : Name : Class : Total Marks : Percentage W.A.P for the following in an interactive manner 1. Prime Number 2. Factorial 3. Table Generation
3
Pag e No.
6 7 8 10 12
Sign .
6.
14
4. Exit
7.
8. 9.
W.A.P to print following output 1 22 333 4444 55555 W.A.P to find whether a given number is Amstrong or not W.A.P to input salary of 10 employees and find the enhanced salary of employees with 15% raise in their salaries. Define a class library which includes of the following data members. Title_book Author B_code Date_issued Date_returned Member Functions: Read_data Compute_data Show_data If the library account holder did not returned the book within 7 days from the date the book issued, then compute fine @ Rs. 20 per day and show the record.
16
18 20
10.
21
11.
23
there is someone on mars you want to talk with, what is the delay between the time a radio signal leaves earth and the time it arrives on mars. Suppose that the light travel approx 18600 miles per second. Now compute the delay, you will need to divide the distance by the speed of light. Display the delay in terms of second and minutes
12.
W.A.P that display the truth table for C#s logical operator (i.e. AND,OR,XOR,NOT) Input the principal, the length of time, number of payments per year and the interest rate from user. Compute the regular payments on a loan by using following formula: Payment= IntRate*(Principal/pay per year) ____________________________ 1-((IntRate/PayperYear)+1)Payperyear*Numyears
24
13
26
14. 15.
W.A.P of Bubble Sort. W.A.P that reads character from the keyboard. Convert lower case letter to uppercase and all uppercase characters to lowercase, display the result make no changes to any other character. The program should stop when the user presses the period key W.A.P that uses an array to find the average of ten double values. Use any double values Write a recursive method that display the content of a string backwards
28 29
16. 17.
30 31
OUTPUT
OUTPUT
} } }
OUTPUT
Console.WriteLine(n+" is odd"); } }
OUTPUT
Q5. Write a program to add marks of student in five subjects and display their his/her details in the following format : Name : Class : Total Marks : Percentage :
PROGRAM :using System; class StudentInfo
10
{ static void Main() {int []marks=new int[5]; String name; String clas; double p; int tm=0; Console.WriteLine("Enter your name "); name=Console.ReadLine(); Console.WriteLine("Enter your class "); clas=Console.ReadLine(); for(int i=0;i<5;i++) {Console.WriteLine("Enter your Marks in "+(i+1)+" Subject"); marks[i]=int.Parse(Console.ReadLine()); tm=tm+marks[i]; } p=tm/5; Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Your Details Are:"); Console.WriteLine("Name:"+name); Console.WriteLine("Class:"+clas); Console.WriteLine("Total Marks:"+tm); Console.WriteLine("Percentage:"+p); } }
OUTPUT
11
Q6. Write a program for the following in an interactive manner 1. Prime Number 2. Factorial 3. Table Generation 4. Exit
PROGRAM :12
using System; class Interactive { public void Prime() {int a,i; Console.WriteLine("enter a no."); a=int.Parse(Console.ReadLine()); if(a==2) {Console.WriteLine(a+" is prime no."); return; } for(i=2;i<a;i++) {int r; r=a%i; if(r==0) {Console.WriteLine(a+" is not a prime"); return; } } if(i==a) {Console.WriteLine(a+" is a prime no."); } } public void Factorial() {int n,d=1; Console.WriteLine("enter the number "); n=int.Parse(Console.ReadLine()); for(int i=n;i>=1;i--) {d=n*d; n--; } Console.WriteLine("The Factorial of the number is="+d); } public void Table() {int n; Console.WriteLine("Enter a no. ");
13
n=int.Parse(Console.ReadLine()); Console.WriteLine("The Table is: "); for(int i=1;i<=10;i++) {Console.WriteLine(n+"*"+i+"="+(n*i)); } } } class InteractiveMainDemo { static void Main() {Interactive i=new Interactive(); int c; Console.WriteLine("Main Menu"); Console.WriteLine("1.Prime Number"); Console.WriteLine("2.Factorial"); Console.WriteLine("3.Table Generation"); Console.WriteLine("4.Exit"); Console.WriteLine("Enter ur Choice "); c=int.Parse(Console.ReadLine()); switch(c) {case 1:i.Prime(); break; case 2:i.Factorial(); break; case 3:i.Table(); break; case 4:return; break; default:
OUTPUT
4444 55555
PROGRAM :using System; class Series { static void Main() { int n; Console.WriteLine("Enter the limit"); n=int.Parse(Console.ReadLine()); Console.WriteLine(); Console.WriteLine(); for(int i=1;i<=5;i++) { for(int j=1;j<=i;j++) {Console.Write(j); } Console.WriteLine();
}
}
OUTPUT
16
{a=n%10; b=a*a*a; c=c+b; n=n/10; } if(m==c) Console.WriteLine(m+" is armstrong"); else Console.WriteLine(m+" is not armstrong"); } }
OUTPUT
18
Q9. Write a program to input salary of 10 employees and find the enhanced salary of employees with 15% raise in their salaries.
PROGRAM :using System; class EmployeeSalaryDemo { static void Main() {int []ei=new int[10]; double []es=new double[10]; for(int i=0;i<10;i++) {Console.WriteLine("enter the emp id of "+(i+1)+" employee"); ei[i]=int.Parse(Console.ReadLine()); Console.WriteLine("enter the salary of "+(i+1)+" employee"); es[i]=double.Parse(Console.ReadLine()); } for(int i=0;i<10;i++) {es[i]=es[i]+(0.15*es[i]); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("The Details are: "); Console.WriteLine("emp_id\tincreased salary"); for(int i=0;i<10;i++) {Console.WriteLine(ei[i]+"\t"+es[i]); } } }
19
OUTPUT
Q-10- Define a class library which includes of the following data members.
Title_book Author B_code Date_issued Date_returned Member Functions: Read_data Compute_data Show_data
20
If the library account holder did not returned the book within 7 days from the date the book issued, then compute fine @ Rs. 20 per day and show the record. PROGRAM :using System; class Library {String Book_Title; String Author; int B_Code,diff,fine; int[] d_i=new int[3]; int[] d_r=new int[3]; public void Read_Data() {Console.WriteLine("enter the title of the book "); Book_Title=Console.ReadLine(); Console.WriteLine("enter the author of the book "); Author=Console.ReadLine(); Console.WriteLine("enter the code of the book "); B_Code=int.Parse(Console.ReadLine()); Console.WriteLine("enter the issue date:"); Console.WriteLine("enter day"); d_i[0]=int.Parse(Console.ReadLine()); Console.WriteLine("enter month"); d_i[1]=int.Parse(Console.ReadLine()); Console.WriteLine("enter year"); d_i[2]=int.Parse(Console.ReadLine()); Console.WriteLine("enter the Return date:"); Console.WriteLine("enter day"); d_r[0]=int.Parse(Console.ReadLine()); Console.WriteLine("enter month"); d_r[1]=int.Parse(Console.ReadLine()); Console.WriteLine("enter year"); d_r[2]=int.Parse(Console.ReadLine()); } public void Compute_Data()
21
} public void Show_Data() {Console.WriteLine(); Console.WriteLine(); Console.WriteLine("The Details are:"); Console.WriteLine("Book Title "+Book_Title); Console.WriteLine("Author "+Author); Console.WriteLine("Book Code "+B_Code); Console.WriteLine("Book Issued in dd-mm-yyyy format:"+d_i[0]+"-"+d_i[1]+"-"+d_i[2]); Console.WriteLine("Book Returned in dd-mm-yyyy format:"+d_r[0]+"-"+d_r[1]+"-"+d_r[2]); Console.WriteLine("Fine Generated "+fine); } }
class LibraryDemo { static void Main() { Library l=new Library(); l.Read_Data(); l.Compute_Data(); l.Show_Data();
22
} }
OUTPUT
Q12. Write a program that display the truth table for C#s logical operator (i.e. AND,OR,XOR,NOT)
PROGRAM :-
23
using System; class TruthTables { public void And() {Console.WriteLine("The AND Table is "); Console.WriteLine("A\tB\toutput"); Console.WriteLine("0\t0\t"+(0*0)); Console.WriteLine("0\t1\t"+(0*1)); Console.WriteLine("1\t0\t"+(1*0)); Console.WriteLine("1\t1\t"+(1*1)); } public void Or() {Console.WriteLine("The OR Table is "); Console.WriteLine("A\tB\toutput"); Console.WriteLine("0\t0\t"+(0+0)); Console.WriteLine("0\t1\t"+(0+1)); Console.WriteLine("1\t0\t"+(1+0)); Console.WriteLine("1\t1\t"+1); } public void Xor() {Console.WriteLine("The XOR Table is "); Console.WriteLine("A\tB\toutput"); Console.WriteLine("0\t0\t"+(0*0)); Console.WriteLine("0\t1\t"+(0+1)); Console.WriteLine("1\t0\t"+(1+0)); Console.WriteLine("1\t1\t"+0); } public void Not() {Console.WriteLine("The NOT Table is "); Console.WriteLine("A\toutput"); Console.WriteLine("0\t"+1); Console.WriteLine("1\t"+0); } } class TruthTablesDemo { static void Main()
24
{TruthTables t=new TruthTables(); int c; Console.WriteLine("MAIN MENU"); Console.WriteLine("1.AND Table"); Console.WriteLine("2.OR Table"); Console.WriteLine("3.XOR Table"); Console.WriteLine("4.NOT Table"); Console.WriteLine("enter ur choice "); c=int.Parse(Console.ReadLine()); switch(c) {case 1:t.And(); break; case 2:t.Or(); break; case 3:t.Xor(); break; case 4:t.Not(); break; case 5:return; break; default:Console.WriteLine("Wrong Choice"); break; } } }
OUTPUT
25
Q13. Input the principal, the length of time, number of payments per year and the interest rate from user. Compute the regular payments on a loan by using following formula: Payment= IntRate*(Principal/pay per year) ____________________________ 1-((IntRate/PayperYear)+1)Payperyear*Numyears
PROGRAM :using System; class LoanPayment { static void Main() {int p,t,ppy; double r,v1,v2,v3,v4,v5; Console.WriteLine("Enter the principal "); p=int.Parse(Console.ReadLine()); Console.WriteLine("Enter the time interval ");
26
t=int.Parse(Console.ReadLine()); Console.WriteLine("Enter the no. of payments per year "); ppy=int.Parse(Console.ReadLine()); Console.WriteLine("Enter the interest rate "); r=float.Parse(Console.ReadLine()); r=r/100; v1=r*(p/ppy); v2=(r/ppy)+1; v3=ppy*t; v4=Math.Pow(v2,v3); v5=1-(v1/v4); Console.WriteLine("The regular payments on a loan are "+v5); } }
OUTPUT
27
for(i=0;i<10;i++) { Console.WriteLine("Enter Value"); q[i]=int.Parse(Console.ReadLine()); } if(j<10) c[j]=p[j]; else c[j]=q[j-10]; for(i=0;i<20;i++) { for(j=0;j<20;j++) { if(c[i]>c[j]) { t=c[i]; c[i]=c[j]; c[j]=t; } } } for(i=0;i<20;i++) { Console.WriteLine (c[i]); } } }
29
Q15.WRITE A PROGRAM that reads charcter from the keyboard. Convert lower case letter to uppercase and all uppercase characters to lowercase, display the result make no changes to any other character. The program should stop when the user presses the period key.
PROGRAM :using System; class ReadString { static void Main() { string str; string str1=""; Console.WriteLine("Enter some characters."); str = Console.ReadLine(); Console.WriteLine("You entered: " + str); foreach(char ch in str) { if(Char.IsLower(ch)) str1+=Char.ToUpper(ch); else str1+=Char.ToLower(ch); } Console.WriteLine("You formatted new string is: " + str1); } }
30
OUTPUT
Q16. WRITE A PROGRAM that uses an array to find the average of ten double values. Use any double values.
PROGRAM :using System; class DoubleAvg { static void Main() {double[] double_values=new double[10]; double s=0,avg; for(int i=0;i<10;i++) {Console.WriteLine("enter "+(i+1)+" value"); double_values[i]=double.Parse(Console.ReadLine()); s=s+double_values[i]; }
31
Q17. Write a recursive method that display the content of a string backwards.
PROGRAM :using System; class RecursiveString { public void DisplayReverse(String str) { if(str.Length>0) DisplayReverse(str.Substring(1,str.Length-1)); else return;
32
Console.Write(str[0]); } } class RecursiveStringDemo { static void Main() {string s; RecursiveString r=new RecursiveString(); Console.WriteLine("enter a string "); s=Console.ReadLine(); Console.WriteLine(); Console.WriteLine("String before recursion "); Console.WriteLine(s); Console.WriteLine(); Console.WriteLine("String after recursion "); r.DisplayReverse(s); } }
OUTPUT
33
34