gdata.io.handleScriptLoaded({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$georss":"http://www.georss.org/georss","xmlns$thr":"http://purl.org/syndication/thread/1.0","xmlns$blogger":"http://schemas.google.com/blogger/2008","id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268"},"updated":{"$t":"2023-07-30T02:11:08.392-07:00"},"category":[{"term":"C Programs"},{"term":"Pointers"},{"term":"string"},{"term":"Array"},{"term":"Learn C"},{"term":"Fundamental"},{"term":"Pattern"},{"term":"control sturctures"},{"term":"searching and sorting"},{"term":"recursion"},{"term":"List of C Programs"},{"term":"Structures"},{"term":"C Turbo Compiler"},{"term":"File Handling"},{"term":"Contents"},{"term":"Common Programming Error"},{"term":"functions"},{"term":"Dynamic memory allcation"}],"title":{"type":"text","$t":"C Programming Tutorial"},"subtitle":{"type":"html","$t":"It is a blog about c programming. Here we provide c programs and tutorials to enhance your skills."},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/-/functions?alt\u003djson-in-script\u0026max-results\u003d50"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/-/functions?alt\u003djson-in-script\u0026max-results\u003d50"},{"rel":"alternate","type":"text/html","href":"http://www.comp-psyche.com/search/label/functions"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"generator":{"version":"7.00","uri":"https://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"3"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"50"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-8152835660017127579"},"published":{"$t":"2014-01-29T04:30:00.000-08:00"},"updated":{"$t":"2014-04-16T01:06:24.004-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"functions"},{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"}],"title":{"type":"text","$t":"C PROGRAMS : FUNCTION"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : FUNCTION\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-function1.html#p6\" name\u003d\"p6\"\u003e6. Write a function that receives a positive integer as input and returns the leading digit in its decimal representation \u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e// For example : the leading digit of 4567 is 4\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint leading_digit(int n)\n{\n // Declaring variable d\u003ddigit to store the digits extracted from number\n int d;\n \n // Performing digit extraction\n while(n)\n {\n  d\u003dn%10;\n  n\u003dn/10;\n }\n \n // Returning leading digit\n return (d);\n}\n\nint main()\n{\n // Declaring variable \"n\" to input a number\n int n;\n \n // Inputting number\n printf(\"Enter any positve integer number : \");\n scanf(\"%d\",\u0026amp;n);\n \n // Calling function and printing result\n printf(\"Leading digit of number : %d \u003d %d \",n, leading_digit(n));\n\u003c/span\u003e\u003c/pre\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\n\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-function1.html#p7\" name\u003d\"p7\"\u003e7. Implement a function that receives an integer value and returns the number of prime factors of that number. If the number is itself a prime number then return 0\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e/*\nFor example : \nfor number 21, the function should return 2 as the prime factors of 21 is 3, 7\nfor number 3, 71 the function should return 0 as 3, 71 are prime numbers\n*/\n \n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint prime_factors(int n)\n{\n // Decaring variable \"i\", \"j\" to iterate loop, c\u003dcounter\n int i, j, c;\n \n // Declaring variable cp\u003dcount prime to count the number of prime numbers\n int cp \u003d 0;\n \n // Determining number of prime factors\n for(i\u003d2; i\u0026lt;\u003dn/2; i++)\n {\n  c\u003d0;\n  if(n%i\u003d\u003d0)\n  { \n  for(j\u003d1; j\u0026lt;\u003di/2; j++)\n  {\n   if(i%j\u003d\u003d0)\n   {\n    c++;\n   }\n  }\n  \n  if(c\u0026lt;\u003d1)\n  {\n   cp++;\n  }\n  }\n  \n }\n \n // Returning number of prime factors\n return (cp);\n \n}\n\n\nint main()\n{\n // Declaring variable \"n\" to input a number\n int n;\n \n // Inputting number\n printf(\"Enter any positve integer number : \");\n scanf(\"%d\",\u0026amp;n);\n \n // Calling funtion and printing result\n printf(\"Number of prime factors of %d \u003d %d \",n, prime_factors(n));\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-function1.html#p8\" name\u003d\"p8\"\u003e8. Program to find maximum number between three numbers\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\n// Function prototype\nint maximum(int x, int y, int z);\n\nint main()\n{\n // Declaring variable n1, n2, n3 to take the input of three numbers\n int n1, n2, n3;\n \n // Inputting value\n printf(\"Enter first number : \");\n scanf(\"%d\",\u0026amp;n1);\n \n printf(\"Enter second number : \");\n scanf(\"%d\",\u0026amp;n2);\n \n printf(\"Enter third number : \");\n scanf(\"%d\",\u0026amp;n3);\n \n // Calling function maximum() and printing the returned maximum value\n printf(\"Maximum between three numbers : %d \", maximum(n1, n2, n3));\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\n\nint maximum(int x, int y, int z)\n{\n // Decalring variable max to store max value\n int max \u003d x; // Assuming x to be maximum\n \n if(max\u0026lt;y)\n {\n  max\u003dy;\n }\n \n if(max\u0026lt;z)\n max\u003dz;\n \n // Returning maximum value\n return (max);\n \n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-function1.html#p9\" name\u003d\"p9\"\u003e9. Program to accept a number and print the sum of given and Reverse number using function\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main( )\n{\n\n // Declaring variable n\u003dto store the entered number by user\n int n; \n\n /* Declaring variable r\u003dreverse to store the reverse of a number, \n s\u003dsum to store the sum of given and reverse number */\n int r, s;\n \n printf(\"Enter a number : \");\n scanf(\"%d\",\u0026amp;n);\n \n // Calling funciton rev and storing the result in \"r\"\n r\u003drev(n);\n \n // Displaying reverse number\n printf(\"Reverse of a number \u003d %d\",r);\n \n // Calling function add\n s\u003dadd(n,r); \n \n // Displaying result or sum\n printf(\"\\nSum of a given and reverse number \u003d %d\",s);\n \n getch( ); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n }\n \n int rev( int n)\n {\n  /* Declaring variable d\u003ddigit to store the extracted digit, \n  rev\u003dreverse to store reversed number */\n  int d,rev\u003d0;\n  \n  while(n\u0026gt;0)\n  {\n   d\u003dn%10;\n   rev\u003drev*10+d;\n   n\u003dn/10;\n  }\n  \n  // Returning reversed number\n  return rev;\n  }\n  \n  int add(int n, int r)\n  {\n   // Returning sum of given and reverse number\n   return n+r;\n  }\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/8152835660017127579/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-function1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/8152835660017127579"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/8152835660017127579"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-function1.html","title":"C PROGRAMS : FUNCTION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-6959814840319685669"},"published":{"$t":"2014-01-29T04:15:00.000-08:00"},"updated":{"$t":"2014-04-16T01:06:26.707-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"functions"},{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"}],"title":{"type":"text","$t":"C PROGRAMS : FUNCTION"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : FUNCTION\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-functions.html#p1\" name\u003d\"p1\"\u003e1.Program to find sum of two numbers using function sum(int,int) that returns sum value \u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint sum( int a, int b )\n{\nreturn a+b;\n}\n\nint main()\n{\n \n// Declaring variable x, y to take the input of two numbers\nint x, y;\n\n// Inputting value\nprintf(\"Enter the value of x:\");\nscanf(\"%d\", \u0026amp;x);\nprintf(\"Enter the value of y:\");\nscanf(\"%d\", \u0026amp;y);\n\n// Displaying value by calling sum function\n printf(\"Sum of %d and %d : %d\", x, y, sum(x, y));\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-functions.html#p2\" name\u003d\"p2\"\u003e2. Program to print the area of a rectangle \u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nvoid area()\n{\n // Declaring variable l\u003dlength, b \u003d breadth\n int l,b;\n \n // Inputting length and breadth \n printf(\"Enter length of rectangle : \");\n scanf(\"%d\",\u0026amp;l);\n \n printf(\"Enter breadth of rectangle : \");\n scanf(\"%d\",\u0026amp;b);\n \n // Calculating and printing area\n printf(\"Area of rectangle %d * %d \u003d %d \", l, b, l*b);\n \n}\n\nint main()\n{\n area();\n\u0026nbsp;\u003c/span\u003e\u003c/pre\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-functions.html#p3\" name\u003d\"p3\"\u003e3. Program to find the factorial of two numbers and add them and print the result \u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\n// Function prototype \nint factorial(int);\n\nint main()\n{\n // Decalring variable n1, n2 to input two number\n int n1, n2;\n \n // Declaring variable f1 and f2 to store the factoial of n1, n2 respectively\n int f1, f2;\n \n // Declaring variable sum to store the sum of f1 and f2\n int sum\u003d0;\n \n // Inputting two numbers\n printf(\"Enter first number : \");\n scanf(\"%d\", \u0026amp;n1);\n \n printf(\"Enter second number : \");\n scanf(\"%d\", \u0026amp;n2);\n \n // Calling function factorial\n f1 \u003d factorial(n1);\n f2 \u003d factorial(n2);\n \n // Calculating sum and displaying result\n sum \u003d f1 + f2;\n\n printf(\"Factorial of first number %d \u003d %d \\n\", n1, f1);\n printf(\"Factorial of second number %d \u003d %d \\n\", n2, f2);\n printf(\"Sum of factorial of two numbers %d and %d \u003d %d \",n1, n2, sum);\n  \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\n\nint factorial(int n)\n{\n // Declaring variable \"i\" to iterate loop\n int i;\n \n // Declaring variabl fact to store factorial\n int fact\u003d1;\n \n // Calculating factorial\n for(i\u003d1;i\u0026lt;\u003dn;i++)\n {\n  fact \u003d fact * i;\n }\n \n // Returning factorial\n return (fact);\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-functions.html#p4\" name\u003d\"p4\"\u003e4. Program to implement functions that returns HCF OR GCD and LCM of two numbers \u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint calculatehcf(int x, int y)\n{\n // Declaring varibale \"i' to iterate loop\n int i;\n \n // Declaring variable hcf to store calculated hcf\n int hcf\u003d1;\n \n for(i\u003d1; i\u0026lt;\u003dx;i++)\n {\n  if(x%i\u003d\u003d0 \u0026amp;\u0026amp; y%i\u003d\u003d0)\n  {\n   hcf\u003di;\n  }\n }\n \n // Returnig hcf\n return hcf;\n}\n\nint calculatelcm(int x, int y, int h) // h is passed value of hcf\n{\n // Declaring variable lcm to store calculated lcm\n int lcm\u003d1;\n \n // lcm is calculated by formula : hcf * lcm \u003d1\n lcm \u003d (x*y)/h;\n \n // Returning lcm\n return lcm;\n}\n\nint main()\n{\n // Declaring variable \"a\" and \"b\" to input two numbers\n int a, b;\n \n /* Declaring variable hcf\u003dto hold hcf returned to it, \n lcm\u003dto hold lcm returned to it */\n int hcf, lcm;\n \n // Inputting two numbers\n printf(\"Enter first number : \");\n scanf(\"%d\", \u0026amp;a);\n \n printf(\"Enter first number : \");\n scanf(\"%d\", \u0026amp;b);\n \n // Calling function calculatehcf\n hcf\u003dcalculatehcf(a, b);\n \n // Calling function calculatelcm\n lcm\u003dcalculatelcm(a, b, hcf);\n \n // Printing hcf and lcm\n printf(\"hcf \u003d %d \",hcf);\n printf(\"\\nlcm \u003d %d \",lcm);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-functions.html#p5\" name\u003d\"p5\"\u003e5. Implement a function that takes two values of integer type and interchange them \u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e// 1. without using Third variable. You may use arithmetic operators\n// 2. With the use of third variable. You should not use arithmetic operator\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nvoid swap_without_third_variable(int a, int b)\n{\n // performing swapping\n a\u003da+b;\n b\u003da-b;\n a\u003da-b;\n \n // Printing interchange value\n printf(\"\\nInterchange value without use of third variable : a\u003d%d, b\u003d%d\", a, b);\n \n}\n\nvoid swap_with_third_variable(int a, int b)\n{\n // Declaring varibale swap to help in interchanging value\n int swap;\n \n // Performing swapping\n swap\u003da;\n a\u003db;\n b\u003dswap;\n \n // Printing interchange value\n printf(\"\\nInterchange value without use of third variable : a\u003d%d, b\u003d%d\", a, b);\n}\n\nint main()\n{\n // Declaring variable a, b to input two numbers\n int a, b;\n \n // Inputting number\n printf(\"Enter value of a : \");\n scanf(\"%d\",\u0026amp;a);\n \n printf(\"Enter value of b : \");\n scanf(\"%d\",\u0026amp;b);\n \n // Printing original value\n printf(\"Orginal value a \u003d %d, b \u003d %d \",a, b);\n \n // Calling functions\n swap_without_third_variable(a, b);\n swap_with_third_variable(a, b);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/6959814840319685669/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-functions.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/6959814840319685669"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/6959814840319685669"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-functions.html","title":"C PROGRAMS : FUNCTION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-5273556307859903472"},"published":{"$t":"2013-11-24T02:04:00.000-08:00"},"updated":{"$t":"2014-04-23T22:51:33.996-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Common Programming Error"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Learn C"},{"scheme":"http://www.blogger.com/atom/ns#","term":"functions"}],"title":{"type":"text","$t":"COMMON PROGRAMMING ERROR - FUNCTION"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003eHere is a list of few common programming errors committed by us in function. For complete list of common programming errors visit : \u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-error-complete-list.html\" target\u003d\"_blank\"\u003eCommon Programming Errors In C\u003c/a\u003e\u003cbr /\u003e\n\u003cul\u003e\u003cli\u003eForget to put a semicolon at the end of prototype or function declaration.\u003c/li\u003e\n\u003cli\u003eSpecifying function parameters of the same type as \u003cspan style\u003d\"color: lime;\"\u003edouble x,y\u003c/span\u003e instead of \u003cspan style\u003d\"color: lime;\"\u003edouble x, double y\u003c/span\u003e results in a compilation error.\u003c/li\u003e\n\u003c/ul\u003e\u003cul\u003e\u003cli\u003ePut a semicolon at the end of function header while defining the function.\u003c/li\u003e\n\u003c/ul\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: yellow;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;For example:\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;float division(float a, int b); \u0026nbsp;// error\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; {\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; return a/b;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; }\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cul\u003e\u003cli\u003eType mismatch error due to difference in the types in function declaration and function definition. The types of parameter may differ.\u003c/li\u003e\n\u003c/ul\u003e\u003cul\u003e\u003cli\u003eType mismatch error due to difference in the order of parameters in function declaration and function definition.\u003c/li\u003e\n\u003c/ul\u003e\u003cul\u003e\u003cli\u003eType mismatch error due to difference in the number of actual arguments and the number of formal arguments.\u003c/li\u003e\n\u003cli\u003eDefining a function inside another function is a syntax error.\u003c/li\u003e\n\u003c/ul\u003e\u003cul\u003e\u003cli\u003eDefining a local variable within a function with the same name as formal argument name.\u003c/li\u003e\n\u003c/ul\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: yellow;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;For example:\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;float division(float a, int b)\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; {\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; int a; //error defining the same variable\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; }\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cul\u003e\u003cli\u003eNot returning any value when the function return type is not valid.\u003c/li\u003e\n\u003c/ul\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: yellow;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; For example:\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; float division(float a, int b)\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; return ;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cbr /\u003e\n\u003c/div\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cdiv\u003e\u003cspan style\u003d\"color: yellow;\"\u003eMore Informative Posts:\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003cul\u003e\u003cli\u003e\u003cspan style\u003d\"color: yellow;\"\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/learn-C.html\"\u003eLearn C\u003c/a\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-error-complete-list.html\"\u003eCommon Programming Error - Complete List\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-errors-array.html\"\u003eCommon Programming Error - Array\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-errors-string.html\"\u003eCommon Programming Error - String\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/5273556307859903472/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2013/11/common-programming-error-function.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/5273556307859903472"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/5273556307859903472"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2013/11/common-programming-error-function.html","title":"COMMON PROGRAMMING ERROR - FUNCTION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}}]}});