帕斯卡,如果其他

以下示例是关于Pascal中包含帕斯卡,如果其他用法的示例代码,想了解帕斯卡,如果其他的具体用法?帕斯卡,如果其他怎么用?帕斯卡,如果其他使用的例子?那么可以参考以下相关示例代码来学习它的具体使用方法。

[英]:pascal if else源码类型:Pascal
Program IfElseInPascal;
Var 
number1, number2 :Integer;

begin
    write('Enter an integer number: ');
    readln(number1);
    
    //Single Line IF-THEN-ELSE STATEMENT
    If number1 > 0 then          // IF statement
        writeln('Number ',number1,' is positive.')
    Else If number1 < 0 then     // ELSE IF statement
        writeln('Number ',number1,' is negative.')
    Else                         // ELSE statement
        Writeln('Number ',number1,' is not positive or negative.');
        
    write('Enter another integer number: ');
    readln(number2);
    
    //Multiple Line IF-THEN-ELSE Statement
    If number2 = number1  then   // IF statement
        begin
        writeln('Numbers entered are the same!');
        number1 := number2 * 2;
        //...more code
        end
    Else                          // ELSE statement
        begin
        writeln('Numbers entered are not the same!');
        number1 := number2 + 2;
        //...more code
        end;
End.

本文地址:https://www.itbaoku.cn/snippets/787520.html