INDEX. Sl. No. Programs Page No. Procedure 2. 1 To check whether person is eligible for vote or not. 2 To find the given number is even or odd 6-8

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

The Hyderabad Public School, Begumpet, Hyderabad, A.P

PROGRAMMING IN C AND C++:

Chapter 5 Conditional and Iterative Statements. Statement are the instructions given to the computer to perform any kind of action.

Examples for Algorithm,Pseduocode,Flowchart

Unit 1: Algorithmic problem solving 1

Chapter 3 Problem Solving and the Computer

VARIABLE, OPERATOR AND EXPRESSION [SET 1]

SHARDAYATAN -E.M STD-10 C-PROGRAMS

WARM UP LESSONS BARE BASICS

PESIT Bangalore South Campus Hosur Road (1km before Electronic City), Bengaluru Department of Basic Science and Humanities

B. V. Patel Institute of Business Management, Computer & Information Technology, UTU 2013

1. Look carefully at the program shown below and answer the questions that follow.

Basic and Intermediate Math Vocabulary Spring 2017 Semester

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR

Unit II. (i) Computer Programming Languages

Syllabus of Diploma Engineering. Computer Engineering. Semester: II. Subject Name: Computer Programming. Subject Code: 09CE1104

INDIAN SCHOOL MUSCAT COMPUTER SCIENCE(083) CLASS XI

SIMPLE I/O WITH PYTHON

Module Contact: Dr Pierre Chardaire, CMP Copyright of the University of East Anglia Version 1


Downloaded from

Computer System and programming in C

CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

Programming Practice (vs Principles)

For the test, be sure to show all work! PROBLEMS: ANSWERS: For problems 1 9, simplify the expression ( ) Evaluate if x = -2 and y = 1 8.

Kadi Sarva Vishwavidyalaya, Gandhinagar

LAB 2.1 INTRODUCTION TO C PROGRAMMING

Control Statements: Part 1

Instructor s Manual. Perl How to Program

SI Networked Computing: Storage, Communication, and Processing, Winter 2009

'C' Programming Language

Selections. CSE 114, Computer Science 1 Stony Brook University

Branching is deciding what actions to take and Looping is deciding how many times to take a certain action.

For Solved Question Papers of UGC-NET/GATE/SET/PGCET in Computer Science, visit

UNIT I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING

Chapter 4 - Notes Control Structures I (Selection)

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

Computers in Engineering COMP 208 Repetition and Storage Michael A. Hawker. Repetition. A Table of Values 9/20/2007

Boolean Expressions. So, for example, here are the results of several simple Boolean expressions:

MODULE 2: Branching and Looping

Chapter 3, Selection. Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved.

These are reserved words of the C language. For example int, float, if, else, for, while etc.

Emil Sekerinski, McMaster University, Winter Term 16/17 COMP SCI 1MD3 Introduction to Programming

Worksheets for GCSE Mathematics. Perimeter & Area. Mr Black's Maths Resources for Teachers GCSE 1-9. Shape

Other operators. Some times a simple comparison is not enough to determine if our criteria has been met.

Hrs Hrs Hrs Hrs Hrs Marks Marks Marks Marks Marks

PROGRAM-ID. BILLING. AUTHOR. GEORGE FOWLER-ED CHRISTENSON. INSTALLATION. TEXAS A & M UNIVERSITY-CSUS. DATE-WRITTEN.

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

MA 511: Computer Programming Lecture 2: Partha Sarathi Mandal

Algorithms and Flowcharts

Solutions: Program 1: Program 2: //To calculate the Gross salary of an Employee

P>80 A P>70 && P<80 B P<70 C 12. Calculate employee salary according to following condition

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.

3 The L oop Control Structure

Lab ACN : C++ Programming Exercises

Chapter 2: Data and Expressions

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++

6. Control Statements II

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING

END-TERM EXAMINATION

Computer science 10 th

Lesson 5: Introduction to the Java Basics: Java Arithmetic THEORY. Arithmetic Operators

Introduction to Python

Decision Structures CSC1310. Python Programming, 2/e 1

Florida Math 0018 Correlation of the ALEKS course Florida Math 0018 to the Florida Mathematics Competencies - Lower

Class 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

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

***********PYTHON PROGRAMS FOR CLASS XI ******************** """ Program to Calculate Simple Interest """ p = eval(input("enter Principle?

PDS Lab Section 16 Autumn Tutorial 1. Unix Commands pwd The pwd command displays the full pathname of the current directory.

Subject: Fundamental of Computer Programming 2068

Introduction of C++ OOP forces us to think in terms of object and the interaction between objects.

Course Outline Introduction to C-Programming

Project 1. due date Sunday July 8, 2018, 12:00 noon


Gujarat University M. Sc. Computer Science [S. F.] Semester-1 Syllabus Gujarat Arts & Science College, Ahmedabad.

Sample Paper Class XI Subject Computer Sience UNIT TEST II

Programming revision. Revision tip: Focus on the things you find difficult first.

Conditional Control Structures. Dr.T.Logeswari

UNDERSTANDING PROBLEMS AND HOW TO SOLVE THEM BY USING COMPUTERS

1 Programming. 1.1 Analyzing a problem

C PROGRAMMING LAB MANUAL

Lesson #4. Logical Operators and Selection Statements. 4. Logical Operators and Selection Statements - Copyright Denis Hamelin - Ryerson University

Programming and Data Structure

Expressions and Variables

ADD Identifier-1 TO Identifier-2 Literal-1. ADD Identifier-1. GIVING Identifier-2 Literal-1

QBASIC Programs SET-3 [SUB and FUNCTION] 1

Lab 1. largest = num1; // assume first number is largest

Chapter 1: Symmetry and Surface Area

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

Chapter Goals. Contents LOOPS

Chapter 2 Writing Simple Programs

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

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

CS110 Introduction to Computing Fall 2006 Midterm Exam

Fundamentals of Programming (Python) Getting Started with Programming

TAKS Mathematics Practice Tests Grade 6, Test B

2008/11/05: Lecture 15 CMSC 104, Section 0101 John Y. Park

Subject: PIC Chapter 2.

Transcription:

INDEX Sl. No. Programs Page No. Procedure 2 1 To check whether person is eligible for vote or not 3-5 2 To find the given number is even or odd 6-8 3 To find the given year is leap year or not 9-11 4 To find area of rectangle on size of option 12-14 5 To find Swapping of numbers 15-17 6 To find temperature conversion 18-20 7 To find area and circumference of a circle 21-23 8 To find largest of three numbers 24-26 9 To find smallest of three numbers 27-29 10 To calculate simple and compound interest 30-32 11 To find reverse of given number and check for palindrome 33-35 1

PROCEDURE Start --> Run CD cobol 1) To Edit NE Filename.cob 2) (To Save and Exit F3 --> E) 3) (To save & be in editor F3 --> S) 4) (To save & Quit F3 --> Q) 5) To Compile Cobol> Cobol filename.cob; No errors or warnings 6) To Run Cobol> Runcob Filename.cob Enter data 2

Program No.1 Program in COBOL to check whether a person Eligible for Vote or not. Algorithm : 1. Execute program 2. Enter Name and Age of a person 3. Check the age of a person 4. If age is equal or greater than 18, then display Eligible to Vote Else Display Not Eligible to Vote 5. Stop 3

Flowchart for the program to check whether a person Eligible for Vote or not. Start Read Name, Age Is Age 18 Yes No Eligible to Vote Not Eligible to Vote Stop 4

CODE : *PROGRAM TO CHEAK WHEATHER A PERSON ELIGIBLE FOR VOTE OR NOT. IDENTIFICATION DIVISION. PROGRAM-ID. VOTE. DATA DIVISION. WORKING-STORAGE SECTION. 77 NAME PIC A(7). 77 AGE PIC 99. PROCEDURE DIVISION. P1. DISPLAY " ENTER THE NAME AND AGE ". DISPLAY " ". ACCEPT NAME. P2. ACCEPT AGE. DISPLAY " ". IF AGE = 18 OR > 18 DISPLAY "******************************* " DISPLAY NAME " IS ELIGIBLE TO VOTE " ELSE DISPLAY "******************************* " DISPLAY NAME " IS NOT ELIGIBLE TO VOTE". DISPLAY "******************************* " STOP RUN. 5

Program No.2 Program in COBOL to find the given number is Even or Odd. Algorithm : 1. Execute program 2. Enter the number 3. Compute : Number % 2 4. If Reminder = 0, then display Given Number is Even Else Display Given Number is Odd 5. Stop 6

Flowchart for the program to find the given number is Even or Odd. Start Read Num Num % 2 Is Rem = 0 Yes No Given Num is Even Given Num is Odd Stop 7

CODE : *PROGRAM TO FIND THE EVEN OR ODD NUMBER. IDENTIFICATION DIVISION. PROGRAM-ID. EO. DATA DIVISION. WORKING-STORAGE SECTION. 77 N PIC 9(3). 77 R PIC 9. PROCEDURE DIVISION. P1. DISPLAY " ENTER THE VALUE OF N". ACCEPT N. DIVIDE N BY 2 GIVING N REMAINDER R. IF (R = 0) DISPLAY " THE GIVEN NUMBER IS EVEN" ELSE DISPLAY " THE GIVEN NUMBER IS ODD". STOP RUN. 8

Program No.3 Program in COBOL to find the given year is Leap year or Not. Algorithm : 1. Execute program 2. Enter the year 3. Compute, Year % 4 4. If Reminder = 0, then display Given Year is Leap year Else Display Given Year is not Leap year 5. Stop 9

Flowchart for the program to find the given year is Leap year or Not. Start Read Year Num % 4 Is Rem = 0 Yes No Given year is Leap year Given year is not Leap year Stop 10

CODE : *PROGRAM TO FIND GIVEN YEAR IS LEAP YEAR OR NOT* IDENTIFICATION DIVISION. PROGRAM-ID. EVEN. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 77 YEAR PIC 9(2). 77 Q PIC 9(2). 77 R PIC 9(2). PROCEDURE DIVISION. P1. DISPLAY " ENTER THE YEAR ". ACCEPT YEAR. P2. DIVIDE YEAR BY 4 GIVING Q REMAINDER R. P3. IF R = 0 DISPLAY " GIVEN YEAR IS LEAP YEAR " ELSE DISPLAY " GIVEN YEAR IS NOT LEAP YEAR ". P4. STOP RUN. 11

Program No.4 Program in COBOL to find area of rectangle on size of option. Algorithm : 1. Execute program 2. Enter the Length and Breadth 3. Compute : A = L * B 4. Check size of A 5. If no size error, then display The area of rectangle is : Else display Insufficient space, want to continue? 6. Enter Ch = Y or N 7. If Ch = Y, then repeat step 2 8. Stop 12

Flowchart for the program to find area of rectangle on size of option. Start Read Length & Breadth Compute A = L * B Is Error Yes Insufficient space. Want to continue? No The Area of Rectangle is Read CH If CH = Y Yes No Stop 13

CODE : *PROGRAM TO FIND AREA OF RECTANGLE ON SIZE OF OPTION IDENTIFICATION DIVISION. PROGRAM-ID RECT. DATA DIVISION. WORKING-STORAGE SECTION. 77 L PIC 9. 77 B PIC 9. 77 A PIC 9. 77 CH PIC 9. PROCEDURE DIVISION. P1. DISPLAY " ENTER LENGTH ". ACCEPT L. DISPLAY " ENTER BREATH ". ACCEPT B. COMPUTE A = L * B ON SIZE ERROR GO TO P2. DISPLAY " AREA = ", A. STOP RUN. P2. DISPLAY "INSUFFICIENT SPACE TO STORE RESULT". DISPLAY "DO YOU WANT TO CONTINUE". ACCEPT CH. IF ( CH = 'Y' OR 'y' ) GO TO P1. 14

Program No.5 Program in COBOL to swapping numbers. Algorithm : 1. Execute program 2. Enter the numbers A and B 3. Display numbers A and B before swapping 4. Swap : C = A, A = B, B = C 5. Display numbers A and B after swapping 6. Stop 15

Flowchart for the program to swapping numbers. Start Read A, B Before Swapping A, B C = A A = B B = C After Swapping A, B Stop 16

CODE : *PROGRAM TO SWAPPING NUMBERS. IDENTIFICATION DIVISION. PROGRAM-ID. SWAP. DATA DIVISION. WORKING-STORAGE SECTION. 77 A PIC 9(2). 77 B PIC 9(2). 77 C PIC 9(2). PROCEDURE DIVISION. P1. DISPLAY "ENTER THE TWO NUMBER". ACCEPT A. ACCEPT B. DISPLAY "--------------------------------------" DISPLAY "BEFORE SWAPPING A = " A " B = " B ". DISPLAY "-------------------------------------" COMPUTE C = A. COMPUTE A = B. COMPUTE B = C. DISPLAY "-------------------------------------" DISPLAY "AFTER SWAPPING A = " A " B = " B ". DISPLAY "-------------------------------------" STOP RUN. 17

Program No.6 Program in COBOL to find temperature conversion. Algorithm : 1. Execute program 2. Enter the temperature in Celsius 3. Convert temperature from Celsius to Fahrenheit, F = C * 1.8 + 32 4. Display temperature in Fahrenheit = F 5. Enter the temperature in Fahrenheit 6. Convert temperature from Fahrenheit to Celsius, C = (F 32) * 1.8 7. Display temperature in Celsius 8. Stop 18

Flowchart for the program to find temperature conversion. Start Read Temp in Celsius F = C * 1.8 + 32 Temp in Fahrenheit = F Read Temp in Fahrenheit C = (F 32) * 1.8 Temp in Celsius Stop 19

CODE : *PROGRAM TO FIND TEMPERATURE CONVERSION* IDENTIFICATION DIVISION. PROGRAM-ID TEMP. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 F PIC 9(3). 01 C PIC 9(3). PROCEDURE DIVISION. P1. DISPLAY " ENTER THE TEMPERATURE IN CELCIUS ". DISPLAY " ". ACCEPT C. COMPUTE F = C * 1.8 + 32. DISPLAY " ". DISPLAY "====================================== ". DISPLAY " TEMPERATURE IN FAREHNIET IS : " F. DISPLAY "====================================== ". DISPLAY " ". DISPLAY " ". DISPLAY " ENTER THE TEMPERATURE IN FAREHNIET". DISPLAY " ". ACCEPT F. COMPUTE C = (F - 32) / 1.8. DISPLAY " ". DISPLAY "====================================== ". DISPLAY " TEMPERATURE IN CELCIUS IS : " C. DISPLAY "====================================== ". STOP RUN. 20

Program No.7 Program in COBOL to find Area and Circumference of a circle. Algorithm : 1. Execute program 2. Enter the radius of a circle 3. Compute, (i) CIR = 2 * PI * R, (ii) A = PI * R ** 2 4. Display Circumference of a circle 5. Display Area of a circle 6. Stop 21

Flowchart for the program to find Area and Circumference of a circle. Start Read Radius = R CIR = 2 * PI * R A = PI * R ** 2 Circumference = CIR Area = A Stop 22

CODE : *AREA AND CIRCUMFERANCE OF A CIRCLE* IDENTIFICATION DIVISION. PROGRAM-ID. CIRC. DATA DIVISION. WORKING-STORAGE SECTION. 77 R PIC 9(2)V99. 77 CIR PIC Z(4).999. 77 A PIC Z(4).999. 77 PI PIC 9(1)V999 VALUE 3.142 PROCEDURE DIVISION. PARA1. DISPLAY " ENTER THE RADIUS ". ACCEPT R. COMPUTE CIR = 2 * PI * R. COMPUTE A = PI * R ** 2. DISPLAY " ". DISPLAY " CIRCUMFERANCE = ", CIR. DISPLAY " AREA = ", A. STOP RUN. 23

Program No.8 Program in COBOL to find Largest of Three numbers. Algorithm : 1. Execute program 2. Enter three numbers A,B,C 3. Check conditions : a) If (A > B) and (A > C), Then Display A is Largest b) If (A < B) and (B > C), Then Display B is Largest c) If (A < B) and (B < C), Then Display C is Largest 4. Stop 24

Flowchart for program to find Largest of Three numbers. Start Read A, B, C If A > B Yes No If A > C Yes No If B > C Yes No B is Largest A is Largest C is Largest Stop 25

CODE : *PROGRAN TO FIND LARGEST OF THREE NUMBERS IDENTIFICATION DIVISION. PROGRAM-ID. BIG. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 77 A PIC 9(2). 77 B PIC 9(2). 77 C PIC 9(2). PROCEDURE DIVISION. P1. DISPLAY "ENTER THE THREE NUMBERS". DISPLAY " ". ACCEPT A. ACCEPT B. ACCEPT C. IF ( A > B ) IF ( A > C ) DISPLAY "=========================" DISPLAY A " IS LARGEST NUMBER " DISPLAY "=========================" ELSE DISPLAY "=========================" DISPLAY C " IS LARGEST NUMBER " DISPLAY "=========================" ELSE IF ( B > C ) DISPLAY "=========================" DISPLAY B " IS LARGEST NUMBER " DISPLAY "=========================" ELSE DISPLAY "=========================" DISPLAY C " IS LARGEST NUMBER " DISPLAY "=========================" STOP RUN. 26

Program No.9 Program in COBOL to find Smallest of Three numbers. Algorithm : 1. Execute program 2. Enter three numbers A,B,C 3. Check conditions : a) If (A < B) and (A < C), Then Display A is Smallest b) If (A > B) and (B < C), Then Display B is Smallest c) If (A > B) and (B > C), Then Display C is Smallest 4. Stop 27

Flowchart for program to find Smallest of Three numbers. Start Read A, B, C If A < B Yes No If A < C Yes No If B < C Yes No B is Smallest A is Smallest C is Smallest Stop 28

CODE : *PROGRAN TO FIND LARGEST OF THREE NUMBERS IDENTIFICATION DIVISION. PROGRAM-ID. BIG. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 77 A PIC 9(2). 77 B PIC 9(2). 77 C PIC 9(2). PROCEDURE DIVISION. P1. DISPLAY "ENTER THE THREE NUMBERS". DISPLAY " ". ACCEPT A. ACCEPT B. ACCEPT C. IF ( A < B ) IF ( A < C ) DISPLAY "=========================" DISPLAY A " IS SMALLEST NUMBER " DISPLAY "=========================" ELSE DISPLAY "=========================" DISPLAY C " IS SMALLEST NUMBER " DISPLAY "=========================" ELSE IF ( B < C ) DISPLAY "=========================" DISPLAY B " IS SMALLEST NUMBER " DISPLAY "=========================" ELSE DISPLAY "=========================" DISPLAY C " IS SMALLEST NUMBER " DISPLAY "=========================" STOP RUN. 29

Program No.10 Program in COBOL to calculate simple and compound interest. Algorithm : 1. Execute program 2. Enter : a) Principle amount = A b) Period = T c) Rate of interest = R 3. Compute : a) SI = ( P * T * R ) / 100 b) A = P * ( 1 + R / 100 ) ** T c) CI = A - P 4. Display Simple Interest =, SI 5. Display Compound Interest =, CI 6. Display Amount =, A 7. Stop 30

Flowchart for program to calculate simple and compound interest. Start Read P, T, R SI = ( P * T * R ) / 100 A = P * ( 1 + R / 100 ) ** T CI = A - P SI, CI, A Stop 31

CODE : *PROGRAM TO CALCULATE SIMPLE AND COMPOUND INTERST IDENTIFICATION DIVISION. PROGRAM-ID. FFF. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 P PIC 9(4). 01 T PIC 99. 01 R PIC 999V99. 01 SI PIC 999.99. 01 CI PIC 999.99. 01 A PIC 9999V99. PROCEDURE DIVISION. P1. DISPLAY " ENTER THE VALUE OF PRINCIPLE AMOUNT ". ACCEPT P. DISPLAY "ENTER THE VALUE OF PRIODE ". ACCEPT T. DISPLAY " ENTER THE VALUE OF RATE OF INTERST ". ACCEPT R. P2. COMPUTE SI = ( P * T * R ) /100. COMPUTE A = P * ( 1 + R / 100 ) ** T. COMPUTE CI = A - P. P3. DISPLAY " SIMPLE INTERST = ", SI. DISPLAY " COMPOUND INTERST = ", CI. DISPLAY " AMOUNT = ", A. STOP RUN. 32

Program No.11 Program in COBOL to find reverse of number and check for palindrome. Algorithm : 1. Execute program 2. Enter the number to find reverse, N 3. Compute, M = N 4. Divide N by 10 giving N reminder R 5. Compute Rev = Rev * 10 + R 6. If N = 0, then Move Rev to Rev1 7. Display Reverse of given number =, Rev1 8. Else go to step 4 9. If Rev = M 10. Display Given number is Palindrome 11. Else Display Given number is not Palindrome 12. Stop 33

Flowchart for program to find reverse of number and check for palindrome. Start Read N Compute M = N N % 10 Rev = Rev * 10 + R No Is N = 0 Yes Is Rev = M No Yes Given No. is Palindrome Reverse of Given Number Given No. is Not Palindrome Stop 34

CODE : *PROGRAM TO FIND REVERSE OF NUMBER AND CHECK FOR PALINDROME IDENTIFICATION DIVISION. PROGRAM-ID. JJ. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 77 N PIC 9(7). 77 R PIC 9(7). 77 REV PIC 9(7) VALUE 0. 77 REV1 PIC Z(7). 77 M PIC 9(7). PROCEDURE DIVISION. P1. DISPLAY " ENTER THE NUMBER TO FIND REVERSE ". ACCEPT N. COMPUTE M = N. P2. DIVIDE N BY 10 GIVING N REMAINDER R. COMPUTE REV = REV * 10 + R. IF N = 0 MOVE REV TO REV1 DISPLAY " REVERSE OF GIVEN NUMBER = ", REV1 ELSE GO TO P2. IF REV = M DISPLAY " GIVEN NUMBER IS PALINDROME " ELSE DISPLAY " GIVEN NUMBER IS NOT PALINDROME ". STOP RUN. 35