13 views

Uploaded by Gagandeep Singh

- CPS125 - Digital Computation and Programming - Course Outline and CMF
- Introduction to C Programming
- C Lab Report
- C Lab Manual
- Data Structures
- pgms
- Write a Program to Compare Two Strings in C Language
- Cds Lab Manual
- Small C compiler - v1.7
- The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
- Sapiens: A Brief History of Humankind
- The Unwinding: An Inner History of the New America
- The Library Book
- Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
- Never Split the Difference: Negotiating As If Your Life Depended On It
- Shoe Dog: A Memoir by the Creator of Nike
- Maybe You Should Talk to Someone: A Therapist, HER Therapist, and Our Lives Revealed
- John Adams
- Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
- Grit: The Power of Passion and Perseverance

You are on page 1of 11

Homework Title / No: 01 Course Instructor: Ruchika Singhal Date of Allotment: 25-jan-2012 Student’s Roll No. RE2R02A52
Course Code: CSE101T Course Tutor (if applicable) : Date of submission: 8th- Feb-2012 Section No.:E2R02
Declaration: I declare that this assignment is my individual work. I have not copied from any other student’s work or from any other source except where due acknowledgment is made explicitly in the text, nor has any part been written for me by another person. Student’s Signature: Gagandeep Singh Evaluator’s comments _____________________________________________________________________ Marks obtained: ___________ out of ______________________ Content of Homework should start from this page only:
Part-A Ques1: Design the flow chart to calculate the energy bill. Read the starting and ending meter reading. The charges are as follows: No of units consumed Rates in (Rs.) 200-500 3.50 100-200 2.50 Less than 100 1.50
Ans. The flow chart given on the next page:-
Ques3: Write an algorithm to find the prime numbers ranges from 1to 200 and also count the total prime numbers which are in the range of 1 to 200. Ans.
Ques2: Write the Pseudo code to enter the temperature in Fahrenheit and convert it Celsius. Formula to convert the temperature is tc = ((tf-32)*5)/9 Ans. Begin Read: tf, tc Print: “enter the temperature in Fahrenheit” a Set: tc = ((tf-32)*5)/9 Print: “tf” End
Ques.4. Company X sells merchandise to wholesale and outlets. Wholesale customers receive a 5% discount on all orders. The company also encourages both wholesale and retail customers to pay the cash on delivery by offering a 3% discount for this method of payment .Another 2% discount is given on orders of 500 or more units’. Each column represents a certain type of order? Draw the decision table?
Ans. The decision table for the following problem on the next page and the rules for table are given as:1. If the wholesale or retail customer orders more than 500 units and they both pay cash on delivery they get 5% discount on order. 2. If the wholesale or retail customer order more than 500 units and not pay cash on the delivery they both get 2% discount on their order. 3. If the wholesale or retail customer orders less than 500 units and pay cash on delivery they get 3% discount on their order.
The decision table for the problem is given as follows:R1 R2 Wholesale or retail customer order more than 500 units Wholesale or retail customer pay cash on delivery 2% discount get 3% discount get 5% discount get Y Y __ __ X Y N X __ __ N Y __ X __ R3
Pat-B Ques.1:Write a program to sort six numbers and find the largest one by Using ladder of if Else. Ans. #include #include void main() { int a,b,c,d,e,f; clrscr(); printf("Enter any six numbers: "); scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f); if((a>b && a>c && a>d && a>e && a>f))
printf(“\n a is greater %d”,a); else if((b>a && b>c && b>d && b>e && b>=f)) printf(“\n b is greater %d”,b); else if((c>a && c>b && c>d && c>e && c>f)) printf(“\n c is greater %d”,c); else if((d>a && d>b && d>e && d>e && d>f)) printf(“\n d is greater %d”,d); else if((e>a && e>b && e>c && e>d && e>f)) printf(“\n e is greater %d”,e); else printf(“\n f is greater %d”,f); getch(); } Ques2: Write a program to find the LCM and HCF of a number Ans. The c program to find LCM and HCF is given as:#include #include void main() { int x,y,i,j,d,e; clrscr(); printf("Enter the two numbers :"); scanf("%d%d",&x,&y); for(i=1,j=1; i<=x,j<=y; i++,j++) { if((x%i==0) && (y%j==0) && (i==j)) d=i;
printf("The hcf of the two numbers in %d",d); } e=(x*y)/d; printf(“\n lcm is:%d”,e); getch(); }
Ques3: Write a program to compute the area of all the mathematical objects like (circle, rectangle, square, triangle etc.); with the help of the program, you are required to demonstrate the difference between variables and constants also. This program must contain all types of variables and constants possible in C Language. Every constant must be initialized and for every variable, user must enter the value at runtime. Test conditions are required to be given for the code Ans. The C program to find the area of circle, square, rectangle, triangle, cylinder etc. with the help of integer variables is given as:#include #include void main( ) { int a,b,c,d,e,f,g ,h,ar1,ar2,ar3,ar4,ar5; clrscr( ); printf(“enter the value of radius of circle:”); scanf(“%d”,&a); printf(“\n enter the side of square:”); scanf(“%d”,&b); printf(“\n enter the length and breath of rectangle:”); scanf(“%d %d”,&c,&d); printf(“\n enter the base and perpendicular length of triangle:”); scanf(“%d %d”,&e,&f);
printf(“\n enter the radius of base and height of a cylinder:”); scanf(“%d %d”,&g,&h); ar1=3.14*a*a; ar2=b*b; ar3=c*d; ar4=(e*f)/2; ar5=2*3.14*g*h; printf(“\n the area of circle:%d\n area of square:%d\n area of rectangle:%d\n area of triangle:%d\n area of cylinder:%d”,ar1,ar2,ar3,ar4,ar5); getch( ); } When we press ctrl+F9 key to see the output the output screen is as OUTPUT SCREEN enter the value of radius of circle:10 enter the side of square:5 enter the length and breath of rectangle:2 3 enter the base and perpendicular length of triangle:4 5 enter the radius of base and height of a cylinder:10 10 the area of circle:314 area of square:25 area of rectangle:6 area of triangle:10 area of cylinder:628 This is the output given by the program it’s output depends upon the values entered by the user.So, this program can calculate every area. But one problem is occur with that
program. It can show output only for integer values. It means if we enter the value of radius of circle in decimal numbers it can’t give the correct value of area of circle because it gives output only in integer can’t give give output in decimal numbers. To solve this problem we have to use the float data type of variable in the place of integer data type. By using float data type we get correct answers in decimal values so if we change the data type in above program we get correct output Then the program looks like this:#include #include void main( ) { ,
Float a,b,c,d,e,f,g,h,ar1,ar2,ar3,ar4,ar5; clrscr( ); printf(“enter the value of radius of circle:”); scanf(“%f”,&a); printf(“\n enter the side of square:”); scanf(“%f”,&b); printf(“\n enter the length and breath of rectangle:”); scanf(“%f %f”,&c,&d); printf(“\n enter the base and perpendicular length of triangle:”); scanf(“%f %f”,&e,&f); printf(“\n enter the radius of base and height of a cylinder:”); scanf(“%f %f”,&g,&h); ar1=3.14*a*a; ar2=b*b; ar3=c*d; ar4=(e*f)/2; ar5=2*3.14*g*h;
printf(“\n the area of circle:%f\n area of square:%f\n area of rectangle:%f\n area of triangle:%f\n area of cylinder:%f”,ar1,ar2,ar3,ar4,ar5); getch( ); } Moreover by this program we get output depending upon the values entered by user. If we want to make same program with float constant the program is as follows:#include #include void main( ) { ,
Float a=1.2,b=1.5,c=2.2,d=1.2,e=1.5,f=0.5,g=10.0,h=5.2,ar1,ar2,ar3,ar4,ar5; clrscr( ); printf(“enter the value of radius of circle:”); scanf(“%f”,&a); printf(“\n enter the side of square:”); scanf(“%f”,&b); printf(“\n enter the length and breath of rectangle:”); scanf(“%f %f”,&c,&d); printf(“\n enter the base and perpendicular length of triangle:”); scanf(“%f %f”,&e,&f); printf(“\n enter the radius of base and height of a cylinder:”); scanf(“%f %f”,&g,&h); ar1=3.14*a*a; ar2=b*b; ar3=c*d; ar4=(e*f)/2; ar5=2*3.14*g*h;
printf(“\n the area of circle:%f\n area of square:%f\n area of rectangle:%f\n area of triangle:%f\n area of cylinder:%f”,ar1,ar2,ar3,ar4,ar5); getch( ); } By doing this program when we run it we get only some constant values of area always. This program depends upon the values of float constant By doing these programs it is clear that variables are the values whose value vary during the execution of program. Constants are predefined and their value remains same during the execution of program. Ques4: Write a program to find the value of following Expression: (e^-x +e^+x)/2 Here e is constant with value 2.71 and x can be any float number. Ans. The c program to find above expression is given as:#include #include #include void main() { float e=2.71, x, a; clrscr( ); printf (“enter the value of x:”); scanf(“%f”,&x); a=(pow(e,-x)+pow(e,x))/2; printf(“%f”,a); getch( ); }
-------------------------------------------End of assignment----------------------------------------

- CPS125 - Digital Computation and Programming - Course Outline and CMFUploaded byHassanKhan
- Introduction to C ProgrammingUploaded byInnah Zaira
- C Lab ReportUploaded byAhsan Ijaz
- C Lab ManualUploaded bylakshmi.s
- Data StructuresUploaded byRizwan Khan
- pgmsUploaded byMansi Dixit
- Write a Program to Compare Two Strings in C LanguageUploaded bySarmad Tabassum
- Cds Lab ManualUploaded byTina Evans
- Small C compiler - v1.7Uploaded byMiguel

- 2013 Bodhi Surf InitiativesUploaded byBodhi Surf
- Zoroaster AmalgamatedUploaded byمرتزآ بهرامی
- Costing model for neonatal screening and diagnosis of haemoglobinopathiesUploaded byapi-3737581
- SignLab9 TrialGuide OnlineUploaded byunoradean
- Time Value of MoneyUploaded bysalman ahmed
- 180810 Tentative Boq DraftUploaded byAsif Mostafa Anik
- PMC Excuse LetterUploaded byMitchie Aban
- icwe- may 3rdUploaded byapi-281816717
- TrustLine Holdings introduces “Intrinsic Series” (PMS), a discretionary portfolio management fund focused on capital preservation with market beating returnsUploaded byRajan Murugesh
- Effects of ChemoUploaded byKrisna Nugraha
- Punjab National Bank Bancmate Customer Case StudyUploaded byYetan Kalra
- 0521615259_Measures,.pdfUploaded bydavid smith
- Criteria and Rationale for PracticumUploaded byMathet Tunguia
- Ejercicio Video 17 y 18 Milan StankoUploaded byAnonymous jqevOeP7
- III SEMUploaded bydivyasd
- Thermal Medicine in Elderly PatientsUploaded byThermalBathsforActiv
- Do_049_s2018 Bridge Aesthetics GuidelinesUploaded byBrian Paul
- Ginsborg, J., & Chaffin, R. (2011). Preparation and Spontaneity in Performance. Psychomusicology- Music, Mind & Brain, 21(1), 137-158.Uploaded bygoni56509
- Director ICT CRA Joseph Kuria County Government Planning And Role Of Data ConnectedEA2015 31-03-15Uploaded byICT AUTHORITY
- deffi helmen 1Uploaded bySaurabh Gupta
- appeasement -shegUploaded byapi-38237833
- jeremy resume1Uploaded byapi-264487290
- Why Home School?Uploaded bySarah Knapp
- 7.2.5.3 Packet Tracer - Configuring IPv6 Addressing Instructions.pdfUploaded byiraqi4ever
- Brooklyn College StatementUploaded byLisa Grass
- Autoregressive conditional heteroskedasticity and changes in regimeUploaded byNeil Lapore
- Michael Hancock: Mayor s Office Anti Fraternization PolicyUploaded byMichael_Lee_Roberts
- Odyssey Marine Exploration, Inc. v. The Unidentified, Shipwrecked Vessel or Vessels - Document No. 26Uploaded byJustia.com
- Red Hat SELinux GuideUploaded byapi-3736383
- Uk Sic Code ListUploaded byvikasgodage