What is difference between functional and imperative programming languages?

后端 未结 10 2142
庸人自扰
庸人自扰 2020-12-12 08:45

Most of the mainstream languages, including object-oriented programming (OOP) languages such as C#, Visual Basic, C++, and Java were designed to primarily support imperative

10条回答
  •  旧巷少年郎
    2020-12-12 09:35

    I know this question is older and others already explained it well, I would like to give an example problem which explains the same in simple terms.

    Problem: Writing the 1's table.

    Solution: -

    By Imperative style: =>

        1*1=1
        1*2=2
        1*3=3
        .
        .
        .
        1*n=n 
    

    By Functional style: =>

        1
        2
        3
        .
        .
        .
        n
    

    Explanation in Imperative style we write the instructions more explicitly and which can be called as in more simplified manner.

    Where as in Functional style, things which are self-explanatory will be ignored.

提交回复
热议问题