CP I LAB MANUAL. Expt No 2 To Check Whether A Year Is A Leap Year Using if-else-if.

Similar documents
PROGRAMMING IN C AND C++:

List of Practical for Class XII Computer Science

Suggestive List of C++ Programs

PROGRAMS. EXCELLENT ACADEMY OF ENGINEERING. Telephone: / NORMAL PROGRAM

Algorithms 4. Odd or even Algorithm 5. Greatest among three numbers Algorithm 6. Simple Calculator Algorithm

UNIVERSITY OF ENGINEERING & MANAGEMENT, KOLKATA C ASSIGNMENTS

END TERM EXAMINATION

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR

PDS Lab (Assignment 1) Date: 31 st July, 2017 (2-6 pm)

Subject: Computer Science

VALLIAMMAI ENGINEERING COLLEGE

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Scheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C

Questions Bank. 14) State any four advantages of using flow-chart

CHOICE BASED CREDIT SYSTEM (With effect from )

ALIGARH MUSLIM UNIVERSITY Department of Computer Science. JAVA Lab Assignment Course: MCA II nd Semester Academic Session:

Write a java program to prints the count of odd and even no s entered.

22316 Course Title : Object Oriented Programming using C++ Max. Marks : 70 Time: 3 Hrs.

Fall Semester (081) Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each.

Computer Programming: C++

Babaria Institute of Technology Computer Science and Engineering Department Practical List of Object Oriented Programming with C

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

PDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs

VARIABLE, OPERATOR AND EXPRESSION [SET 1]

Time: 3 HOURS Maximum Marks: 100

Object Oriented Programming Using C ++ Page No. : 1. ASSIGNMENT SHEET WITHOUT USING OBJECT AND CLASSES

(Following Paper ID and Roll No. to be filled by the student in the Answer Book)

1 Short Answer (15 Points Each)

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.

Object Oriented Programming Using C++ Mathematics & Computing IET, Katunayake

CS201 Some Important Definitions

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

Introduction to Programming Using Java (98-388)

MODULE 2: Branching and Looping

BCA-105 C Language What is C? History of C

MA 511: Computer Programming Lecture 3: Partha Sarathi Mandal

Lab Manual. Program Design and File Structures (P): IT-219

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK

(i) Describe in detail about the classification of computers with their features and limitations(10)

Question Bank (SPA SEM II)

CMPE Experiment 3 Selective Structures

'C' Programming Language

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)

UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter

Examples for Algorithm,Pseduocode,Flowchart

TOPICS TO COVER:-- Array declaration and use.

DC54 DATA STRUCTURES DEC 2014

CS 97SI: INTRODUCTION TO PROGRAMMING CONTESTS. Jaehyun Park

Introduction to C Final Review Chapters 1-6 & 13

AC64/AT64 DESIGN & ANALYSIS OF ALGORITHMS DEC 2014

Assignment: 1. (Unit-1 Flowchart and Algorithm)

Syllabus for Computer Applications

Data Structures using OOP C++ Lecture 3

Rani Durgavati Vishwavidyalaya Jabalpur (M.P.) (UICSA) Master of Computer Application (MCA) Practical List of. MCA III SEM Session -2010

C- PROGRAMMING (3:0:0) Sub code : CS1C01/CS2C01 CIE : 50%Marks Hrs/week : 03 SEE : 50%Marks SEE Hrs : 03 Hours Max. Marks: 100 Course Outcomes:

VALLIAMMAI ENGINEERING COLLEGE

CORE JAVA TRAINING COURSE CONTENT

Object Oriented Programming 2012

COMPUTER APPLICATIONS

XII- COMPUTER SCIENCE VOL-II MODEL TEST I

S Y B Voc Software Development Syllabus

Darshan Institute of Engineering & Technology for Diploma Studies

Dept. of CSE, IIT KGP

MAN4A OBJECT ORIENTED PROGRAMMING WITH C++ Unit I - V

CS 61B Data Structures and Programming Methodology. June David Sun

Object Oriented Programming with Java

n Group of statements that are executed repeatedly while some condition remains true

Unit 3 Decision making, Looping and Arrays

Syllabus Under Autonomy Mathematics

INDIAN SCHOOL MUSCAT COMPUTER SCIENCE(083) CLASS XI

Mathematics. Jaehyun Park. CS 97SI Stanford University. June 29, 2015

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

ESC101N: Fundamentals of Computing End-sem st semester

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007

UNIVERSITY OF MUMBAI T.Y.B.Sc.( INFORMATION TECHNOLOGY) (Semester V) (Practical) EXAMINATION OCTOBER ASP.NET with C# Seat No. : Max.

Iosif Ignat, Marius Joldoș Laboratory Guide 4. Statements. STATEMENTS in C

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

I Year MCA I Semester L T P To C FOUNDATIONS OF INFORMATION TECHNOLOGY

Subject: PIC Chapter 2.

CT 229 Java Syntax Continued

Hrs Hrs Hrs Hrs Hrs Marks Marks Marks Marks Marks

Computer Programming CS F111

VOLUME II CHAPTER 9 INTRODUCTION TO C++ HANDS ON PRACTICE PROGRAMS

How to Design Programs Languages

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

Functions. Arash Rafiey. September 26, 2017

Sri Vidya College of Engineering & Technology

DR. A.P.J. ABDUL KALAM TECHNICAL UNIVERSITY LUCKNOW. Evaluation Scheme & Syllabus. For. B.Tech. First Year (Programming for Problem Solving)

Summer Review for Students Entering Pre-Calculus with Trigonometry. TI-84 Plus Graphing Calculator is required for this course.

FORMULAS to UNDERSTAND & MEMORIZE

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

MATLAB Constants, Variables & Expression. 9/12/2015 By: Nafees Ahmed

Repetition Structures

Transcription:

CP I LAB MANUAL Expt No: 1 To find roots of quadratic equation if-else statement Sample Output Enter the coefficients 1-4 4 The roots are 2 & 2 A 1) start 2) declare the required variables 3) read the coefficients a,b,c of quadratic equation 4) calculate d=b 2-4ac 5) if d<0,display roots are imaginary & goto step 6 else calculate x=(-b+ sqrt(d))/2a y=(-b-sqrt(d))/2a 6) display real roots x,y 7) stop. Expt No 2 To Check Whether A Year Is A Leap Year Using if-else-if. if-else Sample Output Enter Year 2004 It is leap year s 1)start 2)take year as an input. 3)check if year%4=0 and year % 100!= 0 or year%400=0 then print It is a Leap year else print Not a Leap year 4)stop 1)explain if-else control structure. 2)write short note about operators,their precedence and associativity

Expt No: 3 To Implement Calculator Using Multiple If Statements. Switch statement 1)start. 2)declare no1,no2 for two numbers,ch for choice of operation 3)using a do while loop read the nos and choice. if ch=1,add no1,no2. if ch=2,subtract no1,no2. if ch=3,multiply no1,no2. if ch=4,divide no1,no2. 4)display the result of operation 5)stop. Sample Output Enter two nos: 10 20 Ente ur choice: 2 Subtraction: -10 Expt No 4 Calculate Area and Perimeter Of Figures Using Nested Switch Case Nested Switch Syntax 1)start 2)declare variables for radius,length,breath,side,area,perimeter. 3)Input the figure of your choice 4) a)if figure=circle i)read radius. ii)enter the operation i.e area or perimeter if area then area=pi*radius*radius else perimeter=2*pi*radius b)if figure=square i)read side of a square ii)enter the opn area or perimeter if area then area=side*side else perimeter=4*side c)if figure=rectangle i)read length and breath. ii)read the operation to be performed i.e area or perimeter if area then

area=length*breath else perimeter=2*(length+breath) 5)display result 6)stop Expt No: 5 Calculate Sine Of An Angle Up to A Particular Precision. Loop statements 2)declare the required no of variables.'sum' to print sum of the series,'angle' to read value of angle,'term' for generating next term 3)read the angle in degrees 4)convert angle to radians using formula angle=(angle*3.142)/180 5)initialise sum=term=angle and sign=-1,i=1 6)calculate sum=sum+sign*term*angle/(2*i)*(2*i+1) 7)perform sign=sign*-1 8)term=term*angle 2 /(2*i)*(2*i+1) 9)check whether term>0.000001,if true goto step 10 else goto 6 10)print the sine value of an angle 11)stop Sample Output Enter Angle 90 Enter No of Elements 5 Sine 90=1 Expt No 6 Calculate Cosine Of An Angle Upto a Particular Precision. Convertion formulaes 2)Declare the required no of variables.'sum' to print sum of the series,'angle' to read value of angle,'term' for generating next term 3)read the angle in degrees 4)convert angle to radians using formula angle=(angle*3.142)/180 5)initialise sum=0,term=1 and sign=1,i=1 6)calculate sum=sum+sign*term 7)perform sign=sign*-1 and increment i 8)term=term*angle 2 /(2*i)*(2*i-1) 9)check whether term>0.000001,if true goto step 6 else continue 10)print the cosine value of an angle

Sample Output Post lab assignments 11)stop Enter angle in degress :30 Enter upto which term to calculate the series 8 Sin of the angle entered is 0.49967 Expt No: 7 a) To print an inverted number pyramid for the number of rows entered by he user b) to print an alpha triangle Loop statements 2)declare the required no of variables. 'rows' for the no of required rows in the pyramid,'cols' for the no of columns required for the pyramid. 3)read the value for rows from user. 4)initialize the for loop according to the no of rows required. 5)write one for loop nested in the previous for loop to print spacing between nos 6)write second for loop to print the left hand part of the pyramid 7)write third for loop to print the right hand part of the pyramid 8)stop. Sample Output required patterns are: 12345654321 ABCDDCBA 123454321 ABC CBA 1234321 AB BA 12321 A A 121 1 Expt No 8 To write a program to print the following star pattern Basic Control Structures 2)declare the required no of variables. 'rows' for the no of required rows in the pyramid,'cols' for the no of columns required for the pyramid. 3)read the value for rows from user. 4)initialize the for loop according to the no of rows required. 5)write one for loop nested in the previous for loop to print spacing between stars

Sample Output 6)write second for loop to print the upper part of the pyramid 7)end the loops. 8) similarly write next set of for loops to print lower part of the star pattern. 9) End 1) * 2) * *** * * ***** * * * *** * * * * Expt No: 9 Write a program to find maximum of three nos using Inline function Inline functions 2)declare the required no of variables. 3)read the values for three nos from user 4)write an inline function which accepts two parameters and return the max between them. 5)to compute max between three nos first find the maximum of two nos entered by the user by calling inline function. 6)call inline function second time by passing the result of first comparison and the third data value taken from user 7)print the maximum value 8)End. Sample Output Enter two nos: 7 9 max is 9 Expt No 10 Write a program to find Armstrong nos within any range. if-else 2)declare the required no of variables. 3)read the two range values from user 4)within that range for every no check whether no is Armstrong or not using foll

Sample Output steps a)extract every digit of the no using mod operator b)cube it and add it to sum variable which is initialized to 0. c)continue step a & b till no is not equal to 0. d)then check whether sum variable value is same as original no e) if yes print the no otherwise continue with next no. 5)End Enter No 153 Given No is an armstrong No Expt No: 11 Write a program to find all prime nos within a range Nested for loop, break 2)Declare the required no. of variables. 3)read the two range values from user 4)Within that range for every no. check whether no is prime or not using foll steps 5)Write a for loop starting at 2 & ending at sqrt(no) 6)Within a for loop if no. modulo for loop counter is equal to zero,make flag variable 0 else continue. 7)After the end of for loop if flag variable is 1 then display the number as a prime no. 8)End. Sample Output Enter the range: 2 to 15 2 3 5 7 11 13 Expt No 12 Write a program to compute GCD of two numbers using Dijkstra's algorithm using recursive function Recursion 1) Start 2) Declare the required no. of variables. 3) Read the two nos from the user whose GCD is to be computed. 4) Pass the two values to a function which first finds the maximum between the two and then subtracts smaller form the larger. 5) Call the function again with new values.

6) Repeat step 4 & 5 until the two numbers becomes equal. 7) Print a number as GCD. 8) Stop. Sample Output Enter 3 nos 84 18 66 GCD is 6 Expt No: 13 Write a program to overload swap function to interchange two integers values,two float values,two character values Function Overloading 1) Start 2) Declare the required no. of variables. Write three different functions one to swap integer values,one to swap float values and third to swap character values 4) Read the two inputs from the user 5) Call the swap function by passing two inputs as parameter. 6) Print the result 7) End. Sample Output Enter two characters: x = 'A' & y = 'B' after swapping: x = 'B' & y = 'A' Expt No 14 Write a program to find saddle point of a matrix 2D array 1) Start 2) Declare the required no. of variables. 3) Read the data for the no of elements of 2D array 4) Read the elements to be inserted into a matrix. 5) saddle points are of two types a) maximum in the row,minimum in the column. b) minimum in the row,maximum in the column. 6) In a) for every row of the matrix,find the maximum element & check whether that element is minimum in its column.if true then its a saddle point of the matrix. 7) In b) for every row of the matrix,find the minimum element & check whether that element is maximum in its column. if true, then it's a saddle point of matrix.

8) Stop. Sample Output Enter th dimension of the Matrix 3 3 Enter value at [0] [0] 9 Enter value at[0][1] 5 Enter value at[0][2] 6 Enter value at[1][0] 7 Enter value at[1][1] 8 Enter value at[1][2] 1 Enter value at [2][0] 2 Enter value at [2][1] 0 Enter value at [2][2] 1 Saddle Point _>2 Point is located at row position 2 column position 0 Expt No: 15 : : : Write a program to print pascal triangle Two dimensional array 1) Start 2) Read the no of lines 3) fix a two dimensional array with its column elements always less than its no of row element and no of rows according to user input. 4) For the first column assign 1. Also assign 1 where row no = column no 5) The rest pf the places of the matrix are filled as the sum of the previous row elements. 6) Display array 7) Stop Sample Output: 1 1 1 1 2 1 1 3 3 1

Expt No 16 Sample output s Write a program to reverse the words of a String. 2)Read any string from user. 3)Search for a space within a string by checking it's individual character, whenever space is Encountered,reverse all the characters before it. 4)Repeat step 3 till the end of the string is not Encountered 5)Print the string after reversal. 6)Stop Enter string Madam Reverse :Madam Enter string Kats Reverse:stak Expt No: 17 : : : Write a program to find the number of words,characters & lines in any entered string String 2)Read any string from user. 3)Search for a space within a string by checking it's individual character, whenever space is Encountered,increase word count by 1.if fulls top is encountered increment line count by1,else increment character count by 1. 4)Repeat step 3 until the string end is encountered. 5)Stop. Sample Output: C++ programming words: 2 line: 1 characters: 14 : Expt No 18 Write a program to print merit list of students using structures. Structures 2)Create a structure student having a 1-D array for name & marks and float variable

Sample Output s for percentage. 3)Read the data from the user for the student's name, marks and compute percentage. 4)Sort the student records using any sorting method for ex. bubble sort according to their percentages 5)Display the result in tabular form having student's name marks of various subjects & percentage. 6)Stop. 1.Structure Syntax? 2.Difference between array and structure? Expt No 19 Class defination Write a program to simulate saving account processing in a bank using constructors and destructor Object oriented concept Class Account { PRIVATE int acno; float balance; PUBLIC: account(); void getdata(); void display(); void deposit(float amount); this function is used to deposit an amount into account void withdraw(float amount); this function is used to withdraw money from account Sample Output How many customers :1 Enter details for customer:1 Enter new accno:12 Enter opening Bal:1234 Menu 1.Deposit 2.Withdraw 3.Exit Enter your choice(1-3):1 Please enter the customer no:12 Enter amount:3000

Post lab assignment Expt No 20 Write a program to enter the information about student and display it using single inheritance concept Inheritance Class student { Private: int rollno; char name[20]; char sex; Public: void getdata(); void putdata(); }; class physical:public student { private: float height; float weight; }; class academic:public student { private: char trade[20]; int semes; }; Sample Output Enter data Students name:cdf Rollno:10 Sex:m Height:5.7 Weight:55 Academic info... Student name:cdf Rollno:10 trade:computers Sem 6 The entered data is

Physcial Fitness Student Name cdf Rollno:10 Sex:m Height:5.7 Weight:55 Academic fitness Students name:css Rollno:10 Sex:m Trade Computers Semester 6 assignment