Test-1 solutions: 2. Read X and Y values 3. T Y * 2*3.14*X 4. Display T value 5. Stop

Similar documents
To Evaluate an Algebraic Expression

The Utah Basic Skills Competency Test Framework Mathematics Content and Sample Questions

Keystone National Middle School Math Level 8 Placement Exam

3/13/2012. Writing Simple C Programs. ESc101: Decision making using if-else and switch statements. Writing Simple C Programs

Advanced GMAT Math Questions

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

arrays C Programming Language - Arrays

Computer Science 217

Answer: Quantity A is greater. Quantity A: Quantity B:

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators

Sources: On the Web: Slides will be available on:

Assessment For The California Mathematics Standards Grade 6

Section IV.1: Recursive Algorithms and Recursion Trees

Conditionals (with solutions)

How do you compare numbers? On a number line, larger numbers are to the right and smaller numbers are to the left.

The majority of college students hold credit cards. According to the Nellie May

Test 4 Sample Problem Solutions, = , 7 5, = = 1.4. Moving the decimal two spots to the left gives

Mathematics Common Core Sample Questions

Year 9 mathematics: holiday revision. 2 How many nines are there in fifty-four?

Square Roots and the Pythagorean Theorem

Quick Reference ebook

SAMPLE TEST PAPER-1 COMMON APTITUDE TEST (CAT) 2012

To Multiply Decimals

Formulas and Problem Solving

Test A. Calculator not allowed. Mathematics test. First name. Last name. School. DfE no. KEY STAGE LEVELS

Phonics. High Frequency Words P.008. Objective The student will read high frequency words.

A.2. Exponents and Radicals. Integer Exponents. What you should learn. Exponential Notation. Why you should learn it. Properties of Exponents

Scanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard

Five daily lessons. Page 23. Page 25. Page 29. Pages 31

Computer Science 2nd Year Solved Exercise. Programs 3/4/2013. Aumir Shabbir Pakistan School & College Muscat. Important. Chapter # 3.

PowerScore Test Preparation (800)

Python Lists and Loops

Negative Integral Exponents. If x is nonzero, the reciprocal of x is written as 1 x. For example, the reciprocal of 23 is written as 2

Math Questions & Answers

I PUC - Computer Science. Practical s Syllabus. Contents

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

Ratios (pages )

Answer: The relationship cannot be determined.

Chapter One Introduction to Programming

Area and Circumference

XI. Mathematics, Grade 5

5 Mathematics Curriculum

Paper 1. Calculator not allowed. Mathematics test. First name. Last name. School. Remember KEY STAGE 3 TIER 4 6

7 th Grade Integer Arithmetic 7-Day Unit Plan by Brian M. Fischer Lackawanna Middle/High School

Kristen Kachurek. Circumference, Perimeter, and Area Grades Day lesson plan. Technology and Manipulatives used:

Arithmetic Review ORDER OF OPERATIONS WITH WHOLE NUMBERS

VOLUME of Rectangular Prisms Volume is the measure of occupied by a solid region.

Solving Equations With Fractional Coefficients

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

Unit 5 Length. Year 4. Five daily lessons. Autumn term Unit Objectives. Link Objectives

Chapter 3. Input and output. 3.1 The System class

Boolean Algebra Part 1

MATH 90 CHAPTER 6 Name:.

Investigating Relationships of Area and Perimeter in Similar Polygons

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

Lesson 13: The Formulas for Volume

Converting Units of Measure Measurement

4 Mathematics Curriculum

THE UNIVERSITY OF TRINIDAD & TOBAGO

WRITING EQUATIONS USING THE 5-D PROCESS #43

Summer Math Packet. For Students Entering Grade 5 $3.98. Student s Name 63 9 = Review and Practice of Fairfield Math Objectives and CMT Objectives

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Q&As: Microsoft Excel 2013: Chapter 2

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

International Indian School, Riyadh SA1 Worksheet Class: VI Mathematics

Paper 1. Calculator not allowed. Mathematics test. First name. Last name. School. Remember KEY STAGE 3 TIER 5 7

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

Playing with Numbers

Chapter 2: Elements of Java

NMC Sample Problems: Grade 5

Clock Arithmetic and Modular Systems Clock Arithmetic The introduction to Chapter 4 described a mathematical system

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Assessment For The California Mathematics Standards Grade 3

Sample Exit Interview Survey Dual Range Analysis Report

Paper Reference. Ruler graduated in centimetres and millimetres, protractor, compasses, pen, HB pencil, eraser. Tracing paper may be used.

Lesson 21. Circles. Objectives

1) (-3) + (-6) = 2) (2) + (-5) = 3) (-7) + (-1) = 4) (-3) - (-6) = 5) (+2) - (+5) = 6) (-7) - (-4) = 7) (5)(-4) = 8) (-3)(-6) = 9) (-1)(2) =

Scope and Sequence KA KB 1A 1B 2A 2B 3A 3B 4A 4B 5A 5B 6A 6B

Algorithm and Flowchart Structured Programming 1

Math 10 - Unit 3 Final Review - Numbers

In this Chapter you ll learn:

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June Dr.-Ing.

Ready, Set, Go! Math Games for Serious Minds

1 st Grade Math Do-Anytime Activities

SAT Math Facts & Formulas Review Quiz

Most Common Words Transfer Card: List 1

Microsoft Access 3: Understanding and Creating Queries

Paper 1. Mathematics test. Calculator not allowed. First name. Last name. School KEY STAGE TIER

Measurement: Converting Distances

What is Microsoft Excel?

Sample Problems. Practice Problems

PowerScore Test Preparation (800)

Introduction Assignment

The Determinant: a Means to Calculate Volume

Grade 7 & 8 Math Circles October 19, 2011 Prime Numbers

Laboratory Assignments of OBJECT ORIENTED METHODOLOGY & PROGRAMMING (USING C++) [IT 553]

Unit 7 The Number System: Multiplying and Dividing Integers

Transcription:

Test-1 solutions: 1Q(a). One day early morning I found a person in a play ground. He started walking from the center of the play ground and reached the edge of the playground after x meters walking. Later he started running to surround the playground. Totally he completed y rounds. Develop an algorithm to find totally how many meters he runs. 1Ans: 1. Start 2. Read X and Y values 3. T Y * 2*3.14*X 4. Display T value 5. Stop 1Q(b). There are three fruit boxes. We know that one box contains only apples, another box contains only oranges and another box contains both apples and oranges but all these boxes are labeled incorrectly. Write an algorithm to pick out only one fruit from any one box and then correct all labels. 1(b)Ans. 1. Start 2. Pick out a fruit from a box which is having incorrect label A and O 3. if it is Apple fruit then do a. change incorrect label A and O with A. b. change incorrect label O with label A and O c. change incorrect label A with label O else a. change incorrect label A and O with O. b. change incorrect label A with label A and O c. change incorrect label O with label A 4. Stop 1Q(c). In an oil shop, shopkeeper having 3ltr and 5ltr measuring jugs. If he wants to sale 4 litterers oil then how he can measure without using another jug of any size. Develop an algorithm to measure 4ltr oil. 1(c)Ans. 1. Start 2. Take 5 liters oil into 5ltr jug. 3. Pour oil into 3ltr jug from 5ltr jug to fill 3ltr jug. 4. Make empty 3ltr jug. 5. Pour remaining 2ltr oil from 5ltr jug into 3ltr jug. 6. Take 5 liters oil into 5ltr jug second time. 7. Pour oil from 5ltr jug to 3ltr jug to fill the remaining empty place in 3ltr jug. 8. Now you have 4ltr oil in 5ltr jug. 9. Stop (OR) 1Q(d). The distance between two cities (in KM) is input through the keyboard. Write an algorithm to convert and print his distance in meters and centimeters.

1(d)Ans. 1. Start 2. Read X values 3. M X/1000. 4. CM M/100 5. Display M and CM values 5. Stop 1Q(e). The policy followed by a company to process customer orders is given by the following rules. i. If a customer order is less than or equal to that in stock and his credit is OK, supply his requirement. ii. If his credit is not OK do not supply. Send him intimation. iii. If the credit is OK but the item in stock is less than his order, supply what is in stack. Draw the flow chart to implement the company policy. start Read available stock in company Read customer order Order<=stoc Is credit OK? Is credit OK? Supply customer requirement Do not Supply send information Supply available stock to customer Do not Supply send information stop

1Q(f). A particular type of carpet costs Rs.17.45 per square feet. How much will the carpeting cost for two connecting rooms? One room is 16 feet by 24 feet, and the other room is 12 feet by 14 feet. Draw the flow chart for this problem. 1(f)Ans: start Total_cost = (16*24 + 12*14) * 17.45 Display Total_cost stop 2Q(a). Write logical expressions that tests whether a given character variable c is lower case letter, upper case letter, letter digit and white space. 2(a)Ans: logical expression to test lower case letters -- c>= a && c<= z logical expression to test upper case letters -- c>= A && c<= Z logical expression to test digit letters -- c>= 0 && c<= 9 logical expression to test white space letters -- c== \n c== \t c == 2Q(b). Write a statement using conditional operator that will give the smallest of three numbers. 2(b)Ans: small = (a<b)?( (a<c)?(a):(c) ):( (b<c)?(b):(c) ); 2Q(c). 2(c)Ans: int p,q,r; p=3; q = 4; r = 0; r = (p++,q *= p); What are the values of p,q,r after execution of above code segment? p = 4 q = 16 r = 16 (OR) 2Q(d). Find out all possible errors in the following C program and then explain each error why those errors are coming and then correct this program by eliminating those errors so that, to get the expected output. Program to find the area of a triangle:-

int 1st_input_base, _2nd_input_height, Area; printf( /n/t enter 2 input values ); scanf( %d%d,&1st_input_base, &_2nd_input_height) Area == ½*1st_input_base * _2nd_input_height; printf( /nresult = %o,area); 2(d)Ans: Program to find the area of a triangle:- float first_input_base, _2nd_input_height, Area; printf( \n\t enter 2 input values ); scanf( %f%f,&first_input_base, &_2nd_input_height); Area = 0.5*first_input_base * _2nd_input_height; printf( \nresult = %f,area); - Red-colored things are syntax errors. They are corrected in the above program. Compare it with program given in question. - Yellow colored things are not syntax errors. But instead of \n and \t he given /n and /t. but we will not get error. - Brown colored things are run time errors. We will not get expected output because of integer division. 2Q(e). Identify the output of the following C program and then write reason. int a,b,c; a = 034; b = 345; c = a+b; printf("%d",c); c = b-a; printf("%x",c); 2(e)Ans: 373, 13d 2Q(f) Add arithmetic operators(plus, minus, multiply, divide) to make the following expression true: 3 1 3 6 = 8. You can use any parentheses you d like. 2(f)Ans: 3-1%3+6 = 8 3Q(a). Develop an algorithm and program to find the total bill amount in shopping mall by reading total amount for purchased grocery. Service taxes and discounts are calculated as shown below. S.No Bill amount(rs) Service Tax Discount 1 If bill_amount <= 500 5% 1% 2 If bill_amount <= 1500 10% tax for excess of 500 5% discount for excess of 500 3 If bill_amount <=2000 15% tax for excess of 1500 10% discount for excess of 1500 4 If bill_amount <= 2500 20% tax for excess of 2000 15% discount for excess of 2000

5 Else 25% tax for excess of 2500 20% discount for excess of 2500 3(a)Ans: Algorithm: 1. Start 2. Read bill_amount 3. If bill_amount <= 500 then do a. Service_tax = bill_amount/100*5.0 b. Discount = bill_amount/100*1.0 Else if bill_amount <=1500 then do a. Service_tax = 25+(bill_amount-500)/100*10.0 b. Discount = 5 + (bill_amount-500)/100*5.0 Else if bill_amount <=2000 then do a. Service_tax = 125+(bill_amount-1500)/100*15.0 b. Discount = 55+(bill_amount-1500)/100*10.0 Else if bill_amount <=2500 then do a. Service_tax = 200+(bill_amount-2000)/100*20.0 b. Discount = 105+ (bill_amount-2000)/100*15.0 Else if bill_amount > 2500 then do a. Service_tax = 300+(bill_amount-2500)/100*25.0 b. Discount = 180+ (bill_amount-2500)/100*20.0 4. Display total_bill _amount value 5. Stop. Program: float bill_amount,total_bill_amount,service_tax,discount; printf("\n enter bill amount"); scanf("%f",&bill_amount); if(bill_amount<=500.0) service_tax = bill_amount/100*5.0; discount = bill_amount/100*1.0; else if(bill_amount<=1500.0) service_tax = 25.0 + (bill_amount-500)/100*10.0; discount = 5.0 + (bill_amount-500)/100*5.0;

else if(bill_amount<=2000.0) service_tax = 125.0 + (bill_amount-1500)/100*15.0; discount = 55.0 + (bill_amount-1500)/100*10.0; else if(bill_amount<=2500.0) service_tax = 200.0 + (bill_amount-2000)/100*20.0; discount =105.0 + (bill_amount-2000)/100*15.0; else if(bill_amount>2500.0) service_tax = 300.0 + (bill_amount-2500)/100*25.0; discount = 180.0 + (bill_amount-2500)/100*20.0; printf("\ntotal bill amount : %f",total_bill_amount); 3Q(b). If a five digit integer number is input through the keyboard, write a program to calculate the sum of its individual digits. int n,sum=0,d; printf( \n enter 5-digit number ); scanf( %d,&n); n = n/10; n = n/10; n = n/10; n = n/10; printf( %d,sum); 3.c) If the marks obtained by a student in 5 different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100. #include<conio.h> Void main()

int s1,s2,s3,s4,s5; float avg,total,percetage; printf( enter 5 subject marks ); scanf( %d%d%d%d%d,&s1,&s2,&s3,&s4,&s5); total=(s1+s2+s3+s4+s5); avg=total/5.0; percentage=(total/500)*100; printf( average marks=%f,avg); printf( percentage=%f,percentage); (OR) 3. d) Write a program that reads a positive integer and then counts the number of even digits and odd digits. #include<conio.h> int n,r,ecount,ocount; clrscr(); printf( enter an integer number ); scanf( %d,&n); ecount=ocount=0; while(n!=0) r=n%10; if(r%2==0) ecount++; else ocunt++; n=n/10; printf( \nnumber of even digits are %d,ecount); printf( \n number of odd digits are %d,ocount); e) A survey of the computer market shows that personal computers are sold at varying cost by the vendors. The following is the list of costs(in thousands) quoted by some vendors. 35.00, 40.50, 25.00, 31.25, 68.15, 47.00,26.65, 29.00, 53.45, 62.50 Write a program to determine the average cost and the range of values. #include<conio.h> Void main() Float a,b,c,d,e,f,g,h,i,j,avg; a=35.00; b= 40.50;

c= 25.00; d= 31.25; e= 68.15; f= 47.00; g=26.65; h=29.00; i= 53.45; j= 62.50; avg=(a+b+c+d+e+f+g+h)/10.00; printf( \n Average=%f,avg); printf( \n Range of values is 25.00 to 68.15 ); 3Q(f). Analyze outputs of the following two computer programs for all possible inputs and then find out whether these two are generating same outputs for the given all inputs or not. If not explain why they are not same with example. If yes, then create a proper problem statement for the following two programs. int a,b,t; printf( \n enter two numbers ); scanf( %d%d,&a,&b); t = a; a = b; b = t; printf( \na = %d \t b = %d,a,b); int a,b; printf( \n enter two numbers ); scanf( %d%d,&a,&b); a = a*b; b = a/b; a = a/b; printf( \na = %d \t b = %d,a,b); 3f.Ans: Both program will not give same output in all cases. For example if a = 10 and b = 0 in this case first program swap the values of a and b variables. But 2 nd program gives runtime error-divide by zero error.

Problem statement: program to swap the given two variable numbers.