In: Computer Science
Which of the following is not an acceptable symbol for the IF statement:
<>
>
<
>=
<=
Question 2 2 pts
What paragraph can be used in COBOL to define a unique collating sequence or unique addressable character sets?
Mainline
Collate
Sequence
Class
Special-Names
Question 3 2 pts
What is wrong with the following code setup:
01 CARTYPES PIC 99 VALUE ZEROES.
88 FORD PIC 99 VALUE 01.
88 DODGE PIC 99 VALUE 02.
88 MAZDA VALUE 03.
88 HONDA PIC 99 VALUE 04.
Syntax is correct, code would compile
MAZDA does not have a PICTURE clause
PIC should not be on 88 levels
VALUE should be SPACES
VALUE clause should not be on 88 Levels
Question 4 2 pts
Evaluate the following code what would the response be:
01 VALIDCLASSCODES PIC 99 VALUE ZEROES.
88 CISCLASSES VALUE 10.
88 LITCLASSES VALUE 20.
88 MATCLASSES VALUE 30.
88 PHYCLASSES VALUE 40.
(Input VALIDCLASSES = 20)
CISCLASSES
PHYCLASSES
LITCLASSES
MATCLASSES
Question 5 2 pts
What type of control structure is the IF statement?
Selection Structure
Sequence Structure
Definition
Iteration Structure
Control Break
Question 6 4 pts
For an IF statemment, SELECT ALL choices which are required syntax of the IF statement:
(.) Period or END-IF
ELSE
IF
THEN
NEXT SENTENCE
Question 7 2 pts
What is the limit of IF statements in a NESTED IF Statement?
Unlimited if END-IF used
Unlimited
6
3
24
Question 8 2 pts
Given this code, what value will be displayed? WORKING-STORAGE SECTION. 01 WS-COUNTER PIC 9(01) VALUE 0. 01 WS-STATUS PIC 9(01) VALUE 0. PROCEDURE DIVISION. ADD 1 TO WS-COUNTER. IF WS-COUNTER = 1 MOVE 5 TO WS-STATUS ELSE MOVE 2 TO WS-STATUS ADD 3 TO WS-STATUS. DISPLAY WS-STATUS.
3
8
5
0
4
Question 9 2 pts
Given this code, what value will be displayed? WORKING-STORAGE SECTION. 01 WS-COUNTER PIC 9(01) VALUE 0. 01 WS-STATUS PIC 9(01) VALUE 0. PROCEDURE DIVISION. ADD 1 TO WS-COUNTER. IF WS-COUNTER > 1 MOVE 5 TO WS-STATUS IF WS-COUNTER = 2 ADD 1 TO WS-STATUS ELSE MOVE 2 TO WS-STATUS ADD 3 TO WS-STATUS. DISPLAY WS-STATUS.
5
8
2
1
0
Flag this Question
Question 10 5 pts
Assuming this code is correct, which IF statement will result in a TRUE test. Select ALL that apply. WORKING-STORAGE SECTION. 01 FILE-STATUS-FIELDS. 05 INPUT-FILE-01 PIC X(02). 88 GOOD-FILE-01 VALUE '00' '10'. 88 END-OF-FILE-01 VALUE '10'. 05 INPUT-FILE-02 PIC X(02). 88 GOOD-FILE-02 VALUE '00' '23' 88 END-OF-FILE-02 VALUE '10'. PROCEDURE DIVISION. MOVE 00 TO INPUT-FILE-01. MOVE 10 TO INPUT-FILE-02. 1.IF true or true ß true result 2.IF true or false ß true result 3.IF false or true ß true result 4.IF false or false ß false result 5.IF true and true ß true result 6.IF true and false ß false result 7.IF false and true ß false result 8.IF false and false ß false result
IF GOOD-FILE-01 AND NOT GOOD-FILE-02
IF GOOD-FILE-01 OR GOOD-FILE-02
IF NOT GOOD-FILE-01 AND NOT-GOOD-FILE-02
IF GOOD-FILE-01 AND GOOD-FILE-02
IF GOOD-FILE-01 AND END-OF-FILE-01
Answer:
All the symbols we can use in Cobol.
Special-Names paragraph can be used to define a unique collating sequence.
PIC should not be on 88 levels. 88 level number always associated with any other level number 01-49. No PICTURE clause should be in 88 level numbers.
IF statement is the selection structure. We use IF statement to select statement if true this then this. We are selecting statement in this. That’s why it is called Selection Structure.
For an IF statement syntax we need- (.) Period or END-IF, ELSE, IF-THEN, NEXT SENTENCE
There is no limit for IF statements in a NESTED IF Statement.
This code will display 5. Because there is one condition IF WS-COUNTER =1 and in a program, we are adding value 1 to WS-COUNTER, it has value 1 condition is true then the next statement is MOVE 5 TO WS-STATUS. It stores 5 in WS-STATUS and displays this.
This code will display 0. Because WS-COUNTER is not greater than 1 or not equal to 2 then it will nothing store in WS-STATUS. There are two conditions and they are false so it will not proceed next statements.
In last question. I am not understanding that what you want to execute in IF statements, I am answering here the only basis of IF statement, I am telling you when IF statement will give result TRUE. With AND IF both conditions true then it will return TRUE. IF one of them is false it will return FALSE. With OR only one should be TRUE to return TRUE. If both false then it will return FALSE.
1.IF true or true ß true result (This statement will give TRUE). 2.IF true or false ß true result (This statement will give TRUE). 3.IF false or true ß true result (This statement will give TRUE). 4.IF false or false ß false result FALSE 5.IF true and true ß true result (This statement will give TRUE). 6.IF true and false ß false result FALSE 7.IF false and true ß false result FALSE 8.IF false and false ß false result FALSE