Basic Hello World Program
Create a simple Hello World program, compile and execute it.
Create Sample Program
-
An alphabet variable with name @WS-ALPHA having length 5
-
An alphanumeric variable with length 5 and store string “mainframe” in it.
DISPLAY variable -
Define PIC 9(5) for numeric display format. Store value 400000 in it.
-
Define PIC X(10) for character data.
-
Initialize a variable with low values (How will you confirm that the variable contains low values)
-
Initialize a variable with high values (How will you confirm that the variable contains high values)
-
Initialize following group variable with spaces
01 WS-BANREC.
05 WS-BANK-ACC PIC 9(05).
05 FILLER PIC X(01) VALUE ‘-’.
05 WS-CUST-NAME PIC X(20).
05 WS-FILLER PIC X(02).
Declare A Record Structure
Create record structure with:
- Employee name (PIC X(10))
- Employee ID (PIC 9(5))
- Use REDEFINES to treat them as a single PIC X(15) variable.
- DISPLAY final output
Formatted Record Display
Take following record
00001,KIRAN,PATIL,0455.30,20250209,FLAT21 NIGADI PUNE
Display above mentioned record in following format
A/c No: 00001
Name: KIRAN PATIL
Balance: 0455.30
Date: 2025/02/09
Address: FLAT21 NIGADI PUNE
RENAMES
- Personal details (Name, Age, Gender)
- Contact details (Phone, Email)
- Salary details (Basic Pay, Deductions)
Use RENAMES to group: - Personal + Contact details
- Salary details separately
BLANK WHEN ZERO
- Define a numeric variable with 5 digits declaration with “BLANK WHEN ZERO”
- Display variable
- Try to add 100 to the variable and display it
Write a COBOL code snippet using 88-levels to categorize age groups
Child (0-12) Teen (13-19) Adult (20-59) Senior (60 and above)
Declare an alphanumeric variable with length 300. Store text “mainframe” in it and display
Declare a numeric variable with length 50. Store text “mainframe” in it and display
Declare and display variables in COBOL program to get following results(ignore ")
"tinysparksbbbbbbbbbb"
"bbbbbbbbbbtinysparks"
"00000010"
"0100.600"
"-1200.45"
"1200.45+"
Display number -4000 in following formats
9(04)
S9(04)
S9(04) SIGN LEADING
S9(04) SIGN TRAILING
S9(04) SIGN TRAILING SEPARATE
S9(04).9(02)
9(04)V9(02)