Ansi C Balaguruswamy Rapidshare Er

<ul><li>1.Chapter#3 Sr.noTopic DateSign1. Readingstringsfromthekeyboard 9120072. ChangingStringorder 9120073.Morethanoneclass9120074. Assigningvaluestovariables 9120075. Diamondpatternontheconsolescreen 912007 Chapter#4Sr.no TopicDateSign1.IllustratingtheConceptofDeclarationofvariables 16120072. Declaration&amp;Additionsofvariables16120073. Programwithafunction 16120074. DemonstratingBoxing&amp;Unboxing 16120075. Demonstratingadditionofbytetypevariables 16120076.Implementingsomecustomconsoleoutput16120077.Printingahomelikefigureintheconsole 16120078. Executingsomeconsolestatements 1612007 </li></ul><p>2. Chapter#3(OverviewofC#) 3. 3.1ReadingstringsfromthekeyboardusingSystem;classProg3_1{ publicstaticvoidMain(){ Console.Write('EnterYourFirstName:');//Displayingtowritefirstname stringname1=Console.ReadLine();//Savingfirstnameinname1 Console.Write('EnterYourLastName:');//Displayingtowritelastname stringname2=Console.ReadLine();//Savingfirstnameinname2 Console.WriteLine('HelloMr.'+name1+'+name2);//Displayingbothfirst&amp;lastnamesConsole.ReadLine();//Sincetostoptheconsolefordisplayinglastline,weusethistoacceptakeystrokefrmuser.(Similartogetch()inC)}}OUTPUTEnterYourFirstName:DaljitEnterYourLastName:SinghHelloMr.DaljitSingh 4. 3.2ChangingStringorderusingSystem;classProg3_2{ publicstaticvoidMain(String[]args){ Console.Write(args[2]+args[0]+args[1]);}} 5. 3.3MorethanoneclassusingSystem;classClassOne{publicvoidOne()//AfunctionnamedOne{ Console.Write('CSharp');}}classMainly{publicstaticvoidMain()//AfunctionnamedMain(MainFunction){ ClassOnedemoObj=newClassOne();//CreatingojecctofClassOne demoObj.One();//Willdisplay&gt;CSharp Console.Write('Programming');//Willdisplay&gt;Programming//Both'CSharp'&amp;'Programming'willbedisplayedinasinglelineduetothisline&gt;Console.Write('CSharp'); Console.ReadLine();}}OUTPUTCSharpProgramming 6. 3.4AssigningvaluestovariablesusingSystem;classSampleMath{ publicstaticvoidMain() { doublex=2.0;//declaringavariablenamedxoftypedouble&amp;assigningitvalue2.0 doubley=3.0;//declaringavariablenamedyoftypedouble&amp;assigningitvalue3.0 doublez;//declaringavariablenamedzoftypedouble z=x+y; Console.WriteLine('x='+x+',y='+y+'&amp;z='+z); Console.ReadLine(); }} OUTPUTX=2.0,Y=3.0,Z=5.0 7. 3.5DiamondpatternontheconsolescreenusingA=System.Console;classPattern{publicstaticvoidMain(){A.WriteLine('X');A.WriteLine('XXX');A.WriteLine('XXXXX');A.WriteLine('XXX');A.WriteLine('X');A.ReadLine();}} OUTPUTXXXXXXXXX 8. Chapter#4(Literals,Variables&amp;DataTypes) 9. 4.1IllustratingtheConceptofDeclarationofvariablesclassVariable_Concepts{publicstaticvoidMain(){charch=A;//DeclaringaCharactervariablewithvalue=Abytea=50;//Declaringabytevariablewithvalue=50intb=123456789;//DeclaringanIntegervariablewithvalue=123456789longc=1234567654321;//DeclaringaLongtypevariablewithvalue=1234567654321boold=true;//DeclaringaBooleantypevariablewithTRUEvaluefloate=0.000000345F;//Declaringafloattypevariablewithvalue=0.000000345.ThevalueendswithaFresembelingafloatdatatypefloatf=1.23e5F;//Declaringafloattypeexponentialvariablewithvalue=1.23E5=123000.Thevaluecontainsthecharactereresembelinganexponentialvalue.Also,thevalueendswithaFresembelingafloatdatatype.}} 10. 4.2Declaration&amp;AdditionsofvariablesusingSystem;classDeclareAndDisplay{publicstaticvoidmain(){floatx;//Declaringxoffloattypefloaty;//Declaringyoffloattypeintm;//Declaringmofintegertypex=75.86F;y=43.48F;m=x+y;//ThislinewillcreateanERROR.Reasongivenbelow.Console.WriteLine('m=x+y=75.86+43.48='+m);}}//***********************Commentontheoutput*****************//Wedeclared2floattypevariables.//Addedthem//SavedtheresultinanIntegervariable//Sincetheresultofadditionof2floatnumbersisafloatonly...//Wecannotsavethatvalueinanintegervariable.//C#hasstrictcheckfordataconversionstakingplace.//Itdoesnotautomaticallyconvertsalargerdatatypetosmalleronesinceitwillcreatealossofdata.//Forthispurpose,weneedtoexplicitlymaketheintegervariablemtofloattype.//Ifmisalsoafloatvariable,thentheoutputwouldhavebeenlikethis...//m=x+y=75.86+43.48=119.34 11. 4.3ProgramwithafunctionclassABC{staticintm;intn;voidfun(intx,refinty,outintz,int[]a){intj=10;}}//*****************CommentonOutput*******************//Theoutparameterzmustbeassignedtobeforethecontrolleavesthecurrentmethod 12. 4.4DemonstratingBoxing&amp;UnboxingusingSystem;classBoxing{publicstaticvoidmain(string[]a){//************************BOXING**************************intm=10;objectom=m;//createsaboxtoholdmm=20;Console.WriteLine('*************************BOXING********************');Console.WriteLine('m='+m);//m=20Console.WriteLine('om='+om);//om=10Console.ReadLine();//***********************UNBOXING***********************intn=10;objecton=n;//boxn(createsaboxtoholdn)intx=(int)on;//unboxonbacktoanintConsole.WriteLine('*************************UNBOXING********************');Console.WriteLine('n='+n);//n=20Console.WriteLine('on='+on);//on=10Console.ReadLine();}} 13. 4.5DemonstratingadditionofbytetypevariablesusingSystem;classaddition{publicstaticvoidMain(){byteb1;byteb2;intb3;//Wearerequiredtodeclareb3asbyteBUTitsdeclaredasint.Thereasonisgivenbelow.b1=100;b2=200;//Normallythisistheadditionstatement//b3=b1+b2;//Howeveritgivesanerrorthatcannotconvertinttobyte.//Whenb2&amp;b3areadded,wegetanintegervaluewhichcannotbestoredinbyteb1//Thuswewilldeclareb3asintegertype&amp;explicitlyconvertb2&amp;b3toint.b3=(int)b1+(int)b2;Console.WriteLine('b1='+b1);Console.WriteLine('b2='+b2);Console.WriteLine('b3='+b3);Console.ReadLine();}}OUTPUTb1=100b2=200b3=300 14. 4.6ImplementingsomecustomconsoleoutputusingSystem;classDemo{publicstaticvoidMain(){Console.WriteLine('Hello,'Ram'!');//Output&gt;Hello,'Ram'!//Reason&gt;Duetothe'character,thecharactersRamisindoublequotesConsole.WriteLine('*n**n***n****n');//Reason&gt;Duetothencharacter,wegeteachsetof*inanewline.Console.ReadLine();}}OUTPUTHello,Ram!****** 15. 4.7PrintingahomelikefigureintheconsoleusingSystem;classHome{ publicstaticvoidMain() { Console.WriteLine('/'); Console.WriteLine('/'); Console.WriteLine('/'); Console.WriteLine('); Console.WriteLine(''); Console.WriteLine(''); Console.WriteLine(''); Console.WriteLine('nnThisisMyHome.'); Console.ReadLine(); }} OUTPUT/// 16. 4.8ExecutingsomeconsolestatementsusingSystem;classDemo{publicstaticvoidMain(){intm=100;longn=200;longl=m+n;Console.WriteLine('l='+l);Console.ReadLine();//Noerrorintheprogram.}}OUTPUTl=300 17. Chapter#5Sr.noTopic DateSign1.ComputationofIntegerValuestakenfromconsole 30/1/2007 2.ComputationofFloatValuestakenfromconsole 30/1/2007 3. Averageof3numbers30/1/2007 4.Findingcircumference&amp;areaofacircle 30/1/2007 5. Checkingforvalidityofanexpression30/1/2007 6.ConvertingRs.ToPaisa30/1/2007 7.Convertingtemp.fromFahrenheittoCelsius30/1/2007 8. Determiningsalvagevalueofanitem30/1/2007 9.Reading&amp;displayingthecomputedoutputofarealno. 30/1/2007 10. Evaluatingdistancetravelledbyavehicle30/1/2007 11. FindingtheEOQ(EconomicOrderQuantity)&amp;TBO(TimebetweenOrders) 30/1/2007 12. Findingthefrequenciesforarangeofdifferentcapacitance. 30/1/2007 Chapter#6Sr.noTopicDateSign 1. Addingodd&amp;evennosfrom020&amp;addingnos.divisibleby7between100200 6/1/07 2.Findingasolutionoflinearequation 6/1/07 3. Computingmarksofstudents6/1/07 4.Selectingstudentsonthebasisofsomegivencriteriaonmarks 6/1/07 5.PrintingFloydstriangle 6/1/07 6. Computingseasonaldiscountofashowroom6/1/07 7.Readingx,CorrespondinglyPrintingy 6/1/07 18. Chapter#5(Operators&amp;Expressions) 19. 5.1#ComputationofIntegerValuestakenfromconsoleusing System;class integerdemo{public static void Main(){string s1,s2;int a,b;Console.Write('Enter no 1 # '); // Display to enter no. 1s1 = Console.ReadLine (); // save the number in a string variable s1a = int.Parse (s1); // the string s1 is converted into int type variableConsole.Write('Enter no 2 # '); //Display to enter no. 2s2 = Console.ReadLine (); // save the number in a string variable s2b = int.Parse (s2); // the string s2 is cinverted into int type variable// Here er converted both the string variables to int because we wanted to do// integer / numeric manipulation with the inputted string variablesConsole.WriteLine('); // Blank lineConsole.WriteLine('********************* Integer manipulations**********************');Console.WriteLine('); // Blank line// Integer manipulationsConsole.WriteLine('No1 + No2 = ' + (a+b));Console.WriteLine('No1 - No2 = ' + (a-b));Console.WriteLine('No1 / No2 = ' + (a/b));Console.WriteLine('No1 * No2 = ' + (a*b));Console.WriteLine('No1 % No2 = ' + (a%b));Console.ReadLine();}} Output:Enter no 1 # 25Enter no 2 # 15********************* Integer manipulations **********************No1 + No2 = 40No1 - No2 = 10No1 / No2 = 1No1 * No2 = 375No1 % No2 = 10 20. 5.2#ComputationofFloatValuestakenfromconsoleusing System;using System;class floatdemo{public static void Main(){string s1,s2;float a,b;Console.Write('Enter no 1 # '); // Display to enter no. 1s1 = Console.ReadLine (); // save the number in a string variable s1a = float.Parse (s1); // the string s1 is converted into float type variableConsole.Write('Enter no 2 # '); //Display to enter no. 2s2 = Console.ReadLine (); // save the number in a string variable s2b = float.Parse (s2); // the string s2 is cinverted into float type variable// Here er converted both the string variables to float because we wanted todo// float / numeric manipulation with the inputted string variablesConsole.WriteLine('); // Blank lineConsole.WriteLine('********************* Integer manipulations**********************');Console.WriteLine('); // Blank line// Integer manipulationsConsole.WriteLine('No1 + No2 = ' + (a+b));Console.WriteLine('No1 - No2 = ' + (a-b));Console.WriteLine('No1 / No2 = ' + (a/b));Console.WriteLine('No1 * No2 = ' + (a*b));Console.WriteLine('No1 % No2 = ' + (a%b));Console.ReadLine();}}Output:Enter no 1 # 25.64Enter no 2 # 15.87********************* Float manipulations **********************No1 + No2 = 41.51No1 - No2 = 9.77No1 / No2 = 1.615627No1 * No2 = 406.9068No1 % No2 = 9.77 21. 5.3#Averageof3numbersusing System;class average{public static void Main(){float a = 25;float b = 75;float c = 100;float avg = (a+b+c)/3;Console.WriteLine('The average of 25, 75 &amp; 100 = ' + avg);Console.ReadLine();}}Output:The average of 25, 75 &amp; 100 = 6.6666666 22. 5.4 # Findingcircumference&amp;areaofacircleusing System;class circle{public static void Main(){float radius = 12.5F;float circumfrence, area;float pi = 3.1487F;circumfrence = 2 * pi * radius;area = pi * radius * radius;Console.WriteLine('The Radius of the circle = ' + radius);Console.WriteLine('); //Blank LineConsole.WriteLine('Its Circumfrence = ' + circumfrence);Console.WriteLine('Its Area = ' + area);Console.ReadLine();}}Output:The Radius of the circle = 12.5Its Circumference = 78.7175Its area = 491.9844 23. 5.5#Checkingforvalidityofanexpressionusing System;class CheckExpression{public static void Main(){int x,y,a,b;x - y = 100;// gives error//'The left-hand side of an assignment must be a variable, property orindexer'x - (y = 100);// gives error//'Only assignment, call, increment, decrement, and new object expressions// can be used as a statement'}} 24. 5.6 # ConvertingRs.ToPaisausing System;class Money{public static void Main(){float RsF;string s;Console.Write('Enter the amount in Rs. : ');s = Console.ReadLine();RsF = float.Parse(s);Console.WriteLine('Amount in paise = ' +(RsF*100));Console.ReadLine();}}Output:Enter the amount in Rs. : 15Amount in paise = 1500 25. 5.7#Convertingtemp.fromFahrenheittoCelsiususing System;class Temperature{public static void Main(){float fahrenheit,celcius;string s;Console.Write('Enter the temperature in fahrenheit : ');s = Console.ReadLine();fahrenheit = float.Parse(s);celcius = (float)((fahrenheit-32)/1.8);Console.WriteLine('The Temperature in celcius = ' +celcius);Console.ReadLine();}}Output:Enter the temperature in fahrenheit : 98Temperature in celcius = 36.66667 26. 5.8 # Determiningsalvagevalueofanitemusing System;class depreciation{public static void Main(){float depreciation, PurchasePrice, Yrs, SalvageValue;string d,p,y;// string variables are to store the values inputted in the console// each string variable has its character as that of the corresponding// starting character of float type variableConsole.Write('Enter the Depreciation : ');d = Console.ReadLine();depreciation = float.Parse(d);Console.Write('Enter the PurchasePrice : ');p = Console.ReadLine();PurchasePrice = float.Parse(p);Console.Write('Enter the Amount of Years : ');y = Console.ReadLine();Yrs = float.Parse(y);SalvageValue = (float)(PurchasePrice - (depreciation * Yrs));Console.WriteLine('SalvageValue = ' + SalvageValue);Console.ReadLine();}}Output:Enter the Depreciation : 50Enter the PurchasePrice :15000Enter the Amount of Years : 15SalvageValue = 3456.4564 27. 5.11#Evaluatingdistancetravelledbyavehicleusing System;class Distance{public static void Main(){float distance,u,t,a;string u1,t1,a1,reply;// u = Initial velocity// t = Time intervals// a = Acceleration// reply is the value used to check for again restart the program withdifferent valuesint replyforrestart,counter;// replyforrestart will take values either 0 or 1.// 1 means restart for next set of values, 0 means exit the program// counter is used for checking the no. of times the set of values occursConsole.WriteLine('******** This will calculate the distance travelled by avehicle **********');counter = 1;// For the first run, counter = 1startfromhere: // The program will restart from here for another set ofvalues.distance = u = t = a = 0.0F; //resetting all values to 0Console.WriteLine('); // Blank LineConsole.WriteLine('Set of value = ' + counter);// Displays the no. of set of valueConsole.WriteLine('); // Blank LineConsole.Write('Enter the time interval (t) : ');t1 = Console.ReadLine();t = float.Parse(t1);Console.Write('Enter the initial velocity (u) : ');u1 = Console.ReadLine();u = float.Parse(u1);Console.Write('Enter the Acceleration (a) : ');a1 = Console.ReadLine();a = float.Parse(a1);distance = u*t + a*t*t/2;Console.WriteLine('Distance travelled by the vehicle = ' + distance);Console.WriteLine('); // Blank Line 28. Console.Write('Do you want to check for another values (1 for Yes / 0 to Exit)? : ');reply = Console.ReadLine();replyforrestart = int.Parse(reply);if (replyforrestart 1){counter = counter+ 1;Console.WriteLine('); // Blank LineConsole.WriteLine('************************************************************************ ');goto startfromhere;}else{// Do nothing ... Simply program exits} }}Output:******** This will calculate the distance travelled by a vehicle **********Set of value = 1Enter the time interval (t) : 15Enter the initial velocity (u) : 10Enter the Acceleration (a) : 150Distance travelled by the vehicle = 17025Do you want to check for another values (1 for Yes / 0 to Exit) ? : 1************************************************************************Set of value = 2Enter the time interval (t) : 25Enter the initial velocity (u) : 5Enter the Acceleration (a) : 540Distance travelled by the vehicle = 168875Do you want to check for another values (1 for Yes / 0 to Exit) ? : 0...</p>
Programming with ansi c balaguruswamy

Ansi C Balaguruswamy

Ashok N Kamthane Programming With Ansi And Turbo C Pdf ->>->>->> DOWNLOAD (Mirror #1) 1 / 3.

Programming With Ansi C Balaguruswamy

  • Programming in ANSI C by Balaguruswamy - Download as Word Doc (.doc), PDF File (.pdf), Text File (.txt) or read online.
  • 1.E.Balagurusamy- Programming in ANSI C - (TATA McGraw Hill) 4th Edition (EB). (Deitel Publication) 4th Edition / 5th Edition Note: # denotes chapter number. Diploma in Computer Hardware and Networking.