cycle sheet

4
CSE101 COMPUTER PROGRAMMING AND PROBLEM SOLVING LAB CYCLE SHEET 1 FALL SEMESTER ( July,13 December,13 ) S.No PROBLEM STATEMENT All the Programs Must be Implemented in C Programming Language Only CONCEPTS TO USE 1 Write a Program to Display your details in the following format. ******************************* | Name : XXXXXXXX | | Age : XX | | Register Num : XXXXXXXX | | School : XXXXXXXX | ******************************** i) Formatted output(printf) 2 Write a Program to get Phone number (Integer), Age (Integer), Height (Decimal), Sex (Single character ‘M’ or ‘F’) from the user and then display the details. i)Various Data types ii)Input, Output(scanf,printf) 3 Write a Program to Exchange values in two integer variables i) Using a Temporary Variable ii) Without using a Temporary Variable i)Assignment Operator ii)Arithmetic Operator 4 Write a Program to perform basic Arithmetic operations which are Addition, Subtraction, Multiplication, Division and Modulo of Two numbers. Numbers are assumed to be Integers and has to be inputted from the user. i)Arithmetic Operators ii)Decimal Display 5 For the Circuit mentioned above, Get Ra, Rb, Rc, Rd, Re, Rf and Voltage ‘V’ from the user. Then Find and Display Effective Resistance ‘R’(Hint: Ra, Rb are in one series & Rc, Rd, Re, Rf are in another series) and then Display Current which is computed by, I = V/R, then as per Ohms law find and display the Power P which is equal to (I^2) *R Hint : i)Expression Solving ii)Electronics Concepts

Upload: anshul-aggarwal

Post on 22-Dec-2015

7 views

Category:

Documents


1 download

DESCRIPTION

It is a set of questions on c langauge

TRANSCRIPT

Page 1: CYCLE SHEET

CSE101‐COMPUTERPROGRAMMINGANDPROBLEMSOLVING‐LABCYCLESHEET1

FALLSEMESTER(July,13‐December,13) 

S.No PROBLEM STATEMENT  

All the Programs Must be Implemented in C Programming Language Only  

CONCEPTS TO USE 

   1 

 Write a Program to Display your details in the following format.                          *******************************                         |    Name                  :     XXXXXXXX        |                         |    Age                      :     XX                      |                         |    Register Num    :     XXXXXXXX         |                         |    School                 :     XXXXXXXX        |                        ******************************** 

 i) Formatted output(printf) 

 2 

 Write a Program to get Phone number (Integer), Age (Integer), Height (Decimal), Sex (Single character ‐ ‘M’ or ‘F’) from the user and then display the details.  

 i)Various Data types ii)Input, Output(scanf,printf)  

 3 

 Write a Program to Exchange values in two integer variables 

i) Using a Temporary Variable ii) Without using a Temporary Variable 

 

 i)Assignment Operator  ii)Arithmetic  Operator 

 4 

 Write a Program to perform basic Arithmetic operations which are Addition, Subtraction, Multiplication, Division and Modulo of Two numbers. Numbers are assumed to be Integers and has to be inputted from the user.  

 i)Arithmetic Operators  ii)Decimal Display  

 For the Circuit mentioned above, Get Ra, Rb, Rc, Rd, Re, Rf  and Voltage ‘V’ from the user. Then Find and Display Effective Resistance ‘R’(Hint: Ra, Rb are in one series & Rc, Rd, Re, Rf are in another series) and then Display Current which is computed by, I = V/R, then as per Ohms law find and display the Power P  which is equal to (I^2) *R Hint :  

  

        i)Expression Solving  ii)Electronics Concepts 

Page 2: CYCLE SHEET

  Write a Program to find Area and Circumference of Circle. Get the Radius Value from the user. 

Area = π × r2  Circumference = 2 × π × r 

r = radius  

  i)Expression Solving 

 7 

  Write a Program to find whether a number is Odd or Even. Get the number from the user.  

 i)if‐else   ii)Relational Operators  

 8 

  Write a Program to find Greatest and Smallest number out of 3 DIFFERENT numbers. Get 3 different numbers from the User.  

 i)if‐else if –else  ii)Relational and Logical Operators  

 9 

 Display the Grade of a Student for a Course. Obtain the mark for the course from the User. Use if‐else if ‐else construct                    100 >=  Mark  >  90         S                     90 >=  Mark  >  80         A                      80  >=  Mark  > 70         B                                 Mark   < 70         F  

 i)Relational Operators  ii)if‐else if‐else  iii)Logical Operators 

10 

  Write Conversion Programs for the following Measurements. 

i) Kilometer to Miles and vice‐versa ii) Celsius to Fahrenheit and vice‐versa iii) Minutes to Weeks and vice‐versa 

 Hint:  1 Km = 0.621371 miles 1 Celsius = 33.8 Fahrenheit  

 i)Formula Conversions ii)Expression Solving 

 11 

  Write a Program to list all Armstrong numbers present in the range from 1 to 999   Hint: An Armstrong number is a number such that the sum of its digits raised to the third power is equal to the number itself. For example, 371 is an Armstrong number, since 3^3 + 7^3 + 1^3 = 371.  

 Loops(while)  

12 

 Write a Program to convert Binary Number into Decimal number.  

 i)Mod Operation ii)Loop  

13 

 Write a Program to reverse a number. Get the number from the user. Hint:  If A = 3242, then after the logic implementation A should contain 2423.  

  Loop 

Page 3: CYCLE SHEET

14 

  Write a Program to find whether an inputted number is Prime or Not. Use ‘for’ looping for implementation.  

 Loops(for) 

15 

 Write a Program to Print a Pattern similar to the below mentioned one. Get number of levels as input from the user. The example pattern mentioned below has 6 levels(1+2+3+4+5+6=21)  1                    

2  3         4  5  6       7  8  9  10     11  12  13  14  15   16  17  18  19  20  21                       

 

  Nested Loop(while) 

16 

 Write a Program to sum up the digits of a number TILL YOU GET A SINGLE DIGIT SUMMATION VALUE (ie. less than 10). Use Nested Loop to implement. Hint :  For example, the number is 4545   sum = 4 + 5 + 4 + 5 = 99 ( since…99 is > 10) sum = 9 + 9 = 18 (since 18 is > 10) sum = 1 + 8 =9 ( 9 is < 10 ) Answer is 9  

 Nested Loop  

17  Write a Program to find Factorial of an inputted Number. Use ‘do‐while’ looping to implement.  

Loop (do‐while) 

18 

 Write a Program to find GCD (Greatest Common Divisor) of  two integers. Get the integers as input from the user. 

i) Using Normal Method ( Hint : Loop and Division) ii) Using Euclidean Method  

 Hint (Euclidean Method) Input                :    Input Two positive integers a and b Output             :   The greatest common divisor ,g, of a and b Computation  :  i) If  (a < b), exchange a and b ii) Divide a by b and get the remainder, r, If r == 0 report b as the GCD of a and b. Exit iii) If  r!= 0, Replace a by b and replace b by r. Return to the Previous Step. 

 At each step, remainder, r, decreases by at least 1.Therefore r must eventually be 0. 

 

  

     i)Algorithm Implementation  ii)Loops  iii)Switch‐case 

Page 4: CYCLE SHEET

19 

  Write a Program to display Fibonacci Series up to ‘n’ terms. Get ‘n’ value from the user. Use do‐While loop  

 Loop (do‐while)  

 20 

  Write a Program to calculate the Summation of following Series up to n terms. Get the n value from the user. 

i) ∑ (2 ,  2 ,  3 , 4 , 5, 6 ,7, 8 , 11 , 10, 13 ,12 , 17 ……. up to ‘n’ terms) ii) ∑ (0 ,  3 , 15 , 24 , 35 , 48 ,  63 …… up to ‘n’ terms) iii) ∑ (1 ,  ( ‐2/8) ,  ( 3/9) , ( ‐4/64) , ( 5/25) , ( ‐6/216)….. up to ‘n’ terms ) 

 

  i)Arithmetic and Geometric Sequences ii)Loop iii)Nested Loop