Deprecated: Optional parameter $i declared before required parameter $data is implicitly treated as a required parameter in /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php on line 4

Deprecated: Optional parameter $i declared before required parameter $data is implicitly treated as a required parameter in /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php on line 245

Deprecated: Optional parameter $output declared before required parameter $attr is implicitly treated as a required parameter in /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/snippets.php on line 431

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/mega-menu.php on line 147

Warning: Cannot modify header information - headers already sent by (output started at /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php:4) in /home4/aipsa9vw/public_html/blogs/wp-includes/rest-api/class-wp-rest-server.php on line 1909

Warning: Cannot modify header information - headers already sent by (output started at /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php:4) in /home4/aipsa9vw/public_html/blogs/wp-includes/rest-api/class-wp-rest-server.php on line 1909

Warning: Cannot modify header information - headers already sent by (output started at /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php:4) in /home4/aipsa9vw/public_html/blogs/wp-includes/rest-api/class-wp-rest-server.php on line 1909

Warning: Cannot modify header information - headers already sent by (output started at /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php:4) in /home4/aipsa9vw/public_html/blogs/wp-includes/rest-api/class-wp-rest-server.php on line 1909

Warning: Cannot modify header information - headers already sent by (output started at /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php:4) in /home4/aipsa9vw/public_html/blogs/wp-includes/rest-api/class-wp-rest-server.php on line 1909

Warning: Cannot modify header information - headers already sent by (output started at /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php:4) in /home4/aipsa9vw/public_html/blogs/wp-includes/rest-api/class-wp-rest-server.php on line 1909

Warning: Cannot modify header information - headers already sent by (output started at /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php:4) in /home4/aipsa9vw/public_html/blogs/wp-includes/rest-api/class-wp-rest-server.php on line 1909

Warning: Cannot modify header information - headers already sent by (output started at /home4/aipsa9vw/public_html/blogs/wp-content/themes/voice/include/modules.php:4) in /home4/aipsa9vw/public_html/blogs/wp-includes/rest-api/class-wp-rest-server.php on line 1909
{"id":347,"date":"2023-01-19T14:00:36","date_gmt":"2023-01-19T14:00:36","guid":{"rendered":"https:\/\/aipsacademy.com\/blogs\/?p=347"},"modified":"2023-01-19T14:00:37","modified_gmt":"2023-01-19T14:00:37","slug":"functions-in-c-programming-language-2","status":"publish","type":"post","link":"https:\/\/aipsacademy.com\/blogs\/2023\/01\/19\/functions-in-c-programming-language-2\/","title":{"rendered":"Functions in C++ Programming Language"},"content":{"rendered":"\n
\n

The number of statements grouped in a logical units to perform some specific task , are called functions.<\/strong><\/p>\n\n\n\n

Function makes program easier to understand and maintain . <\/em><\/p>\n\n\n\n

when a program<\/a> is made using function that can be easily modified and error can be detected.<\/p>\n\n\n\n

A large program is divided into several functions to handle in easy way.<\/p>\n<\/div><\/div>\n\n\n\n

\n

There are two types of function.<\/p>\n\n\n\n

  1. Library function \/ Built in function<\/li>
  2. User defined function.<\/li><\/ol>\n<\/div><\/div>\n\n\n\n

    Library Function<\/h3>\n\n\n\n
    \n
    \n

    The predefined function is called library function. <\/p>\n\n\n\n

    we can use library function using their respective header files. <\/p>\n\n\n\n

    If we use library functions and respective header file is not included then we get Prototype error.<\/p>\n\n\n\n

    we can’t understand the internal working of the library function.<\/p>\n\n\n\n

    example: sqrt( ), pow( ), strlen( ) , etc…<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n

    User defined function<\/h2>\n\n\n\n

    The function defined by the user is called user defined function. <\/p>\n\n\n\n

    we can understand the structure of the user defined function. <\/p>\n\n\n\n

    we can modify user defined function when needed .<\/p>\n\n\n\n

    It can be used in four ways.<\/p>\n\n\n\n

    1. No Argument, No Return value<\/li>
    2. With Argument, But not Return value<\/li>
    3. With Argument , with Return value<\/li>
    4. No Argument, but return value<\/li><\/ol>\n\n\n\n

      <\/p>\n\n\n\n

      Parts of Functions:<\/h2>\n\n\n\n

      There are following part of function.<\/p>\n\n\n\n

      1. Function prototyping:- It determines the function name,number of arguments and their types, return type etc..<\/li>
      2. Function call:- When we want to execute the statements of function then we need function calling. function is invoked or called with parameters or arguments.<\/li>
      3. Function definition :- It contains the statement, which to be performed after calling.<\/li>
      4. Actual argument:- Argument inside the function call is known as actual argument.<\/li>
      5. Formal Argument:- Argument inside the function definition is called formal argument.<\/li><\/ol>\n\n\n\n

        No Argument , No Return Value<\/h4>\n\n\n\n

        example<\/p>\n\n\n\n

        void sum(); \/\/ prototyping part\nvoid main()\n{\n......\n......\n.......\nsum(); \/\/ calling part\ngetch();\n}\nvoid sum()\n{\n.....\n......\/\/Definitioin part\n\n}<\/code><\/pre>\n\n\n\n

        Q.Write a program to find sum of two numbers using No argument , No return value.(compile time)<\/p><\/blockquote>\n\n\n\n

        #include<iostream.h>\n#include<conio.h>\nvoid sum();\nvoid main()\n{\nclrscr();\nsum();\ngetch();\n}\nvoid sum()\n{\nfloat a,b,c;\na=10;\nb=20;\nc=a+b;\ncout<<\u201dSum=\u201d<<c;\n}\n<\/code><\/pre>\n\n\n\n

        Output<\/p>\n\n\n\n

        Sum=30<\/p>\n\n\n\n

        Q.Write a program to find sum of two numbers using No argument , No return value.(Run time)<\/p><\/blockquote>\n\n\n\n

        #include<iostream.h>\n#include<conio.h>\nvoid sum();\nvoid main()\n{\nclrscr();\nsum();\ngetch();\n}\nvoid sum()\n{\nfloat a,b,c;\ncout<<\u201dEnter value of a and b=\u201d;\ncin>>a>>b;\nc=a+b;\ncout<<\u201dSum=\u201d<<c;\n}\n<\/code><\/pre>\n\n\n\n

        output<\/p>\n\n\n\n

        \n

        Enter value of a and b=10<\/p>\n\n\n\n

        20<\/p>\n\n\n\n

        sum=30<\/p>\n<\/div><\/div>\n\n\n\n

        With Argument , But not Return Value<\/h4>\n\n\n\n

        Example<\/p>\n\n\n\n

        void sum(float ,float); \/\/ prototyping part\nvoid main()\n{\nfloat a,b;\na=10;\nb=20;\n......\n.......\nsum(a,b); \/\/ calling part, Actual argument\ngetch();\n}\nvoid sum(float x,float y)  \/\/ formal argument\n{\nfloat z;\nz=x+y;\ncout<<\"sum=\"<<z;\n......\/\/Definitioin part\n\n}<\/code><\/pre>\n\n\n\n

        Q.Write a program to find sum of two numbers using with argument , but not return value.(compile time)<\/p><\/blockquote>\n\n\n\n

        #include<iostream.h>\n#include<conio.h>\nvoid sum(float,float);\nvoid main()\n{\nclrscr();\nfloat a,b;\na=10;\nb=20;\nsum(a,b);\ngetch();\n}\nvoid sum(float x, float y)\n{\nfloat z;\nz=x+y;\ncout<<\u201dSum=\u201d<<z;\n}\n<\/code><\/pre>\n\n\n\n

        Output<\/p>\n\n\n\n

        sum=30<\/p>\n\n\n\n

        Q.Write a program to find sum of two numbers using with argument , but not return value.(Run time)<\/p><\/blockquote>\n\n\n\n

        #include<iostream.h>\n#include<conio.h>\nvoid sum(float,float);\nvoid main()\n{\nclrscr();\nfloat a,b;\ncout<<\u201dEnter value of a and b=\u201d;\ncin>>a>>b;\nsum(a,b);\ngetch();\n}\nvoid sum(float x, float y)\n{\nfloat z;\nz=x+y;\ncout<<\u201dSum=\u201d<<z;\n}\n<\/code><\/pre>\n\n\n\n

        Output<\/p>\n\n\n\n

        \n

        Enter value of a and b=10<\/p>\n\n\n\n

        20<\/p>\n\n\n\n

        sum=30<\/p>\n<\/div><\/div>\n\n\n\n

        With Argument, With Return value<\/h4>\n\n\n\n

        Example<\/p>\n\n\n\n

        float sum(float ,float); \/\/ prototyping part\nvoid main()\n{\nfloat a,b,c;\na=10;\nb=20;\n......\n.......\nc=sum(a,b); \/\/ calling part, Actual argument\ncout<<\"Sum=\"<<c;\ngetch();\n}\nfloat sum(float x,float y)  \/\/ formal argument\n{\nfloat z;\nz=x+y;\nreturn z;\n......\/\/Definitioin part\n\n}<\/code><\/pre>\n\n\n\n

        Q.Write a program to find sum of two numbers using with argument , with return value.(compile time)<\/p><\/blockquote>\n\n\n\n

        #include<iostream.h>\n#include<conio.h>\nfloat sum(float,float);\nvoid main()\n{\nclrscr();\nfloat a,b,c;\na=10;\nb=20;\nc=sum(a,b);\ncout<<\u201dSum=\u201d<<c;\ngetch();\n}\nfloat sum(float x, float y)\n{\nfloat z;\nz=x+y;\nreturn z;\n}\n<\/code><\/pre>\n\n\n\n

        Output<\/p>\n\n\n\n

        sum=30<\/p>\n\n\n\n

        Q.Write a program to find sum of two numbers using with argument , with return value.(Run time)<\/p><\/blockquote>\n\n\n\n

        #include<iostream.h>\n#include<conio.h>\nfloat sum(float,float);\nvoid main()\n{\nclrscr();\nfloat a,b,c;\ncout<<\u201dEnter value of a and b=\u201d;\ncin>>a>>b;\nc=sum(a,b);\ncout<<\u201dSum=\u201d<<c;\ngetch();\n}\nfloat sum(float x, float y)\n{\nfloat z;\nz=x+y;\nreturn z;\n}\n<\/code><\/pre>\n\n\n\n

        Output<\/strong><\/p>\n\n\n\n

        \n
        \n

        Enter value of a and b=10<\/p>\n\n\n\n

        20<\/p>\n\n\n\n

        sum=30<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n

        <\/p>\n\n\n\n

        to be continued…..check Regular for more…..update<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"

        The number of statements grouped in a logical units to perform some specific task , are called functions. Function makes program easier to understand and maintain . when a program is made using function that can be easily modified and error can be detected. A large program is divided into several functions to handle in […]<\/p>\n","protected":false},"author":1,"featured_media":348,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5,7,6,8],"tags":[],"class_list":["post-347","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-11th-computer-science","category-12th-computer-science","category-cbse","category-jac","category-jac-12th-computer-science"],"_links":{"self":[{"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/posts\/347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/comments?post=347"}],"version-history":[{"count":1,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":349,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/posts\/347\/revisions\/349"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/media\/348"}],"wp:attachment":[{"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/media?parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/categories?post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aipsacademy.com\/blogs\/wp-json\/wp\/v2\/tags?post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}