// API callback
relpostimgcuplik({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268"},"updated":{"$t":"2023-07-30T02:11:08.392-07:00"},"category":[{"term":"C Programs"},{"term":"Learn C"},{"term":"Common Programming Error"},{"term":"searching and sorting"},{"term":"control sturctures"},{"term":"Fundamental"},{"term":"List of C Programs"},{"term":"string"},{"term":"Array"},{"term":"Pattern"},{"term":"Contents"},{"term":"Pointers"},{"term":"functions"},{"term":"Dynamic memory allcation"},{"term":"recursion"},{"term":"C Turbo Compiler"},{"term":"File Handling"},{"term":"Structures"}],"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.comp-psyche.com\/feeds\/posts\/default"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/-\/functions?alt=json-in-script\u0026max-results=50"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/search\/label\/functions"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"generator":{"version":"7.00","uri":"http://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":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"functions"}],"title":{"type":"text","$t":"C PROGRAMS : FUNCTION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : FUNCTION\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p6\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint leading_digit(int n)\n{\n \/\/ Declaring variable d=digit to store the digits extracted from number\n int d;\n \n \/\/ Performing digit extraction\n while(n)\n {\n  d=n%10;\n  n=n\/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 = %d \",n, leading_digit(n));\n\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\n\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p7\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint prime_factors(int n)\n{\n \/\/ Decaring variable \"i\", \"j\" to iterate loop, c=counter\n int i, j, c;\n \n \/\/ Declaring variable cp=count prime to count the number of prime numbers\n int cp = 0;\n \n \/\/ Determining number of prime factors\n for(i=2; i\u0026lt;=n\/2; i++)\n {\n  c=0;\n  if(n%i==0)\n  { \n  for(j=1; j\u0026lt;=i\/2; j++)\n  {\n   if(i%j==0)\n   {\n    c++;\n   }\n  }\n  \n  if(c\u0026lt;=1)\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 = %d \",n, prime_factors(n));\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p8\" name=\"p8\"\u003E8. Program to find maximum number between three numbers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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 = x; \/\/ Assuming x to be maximum\n \n if(max\u0026lt;y)\n {\n  max=y;\n }\n \n if(max\u0026lt;z)\n max=z;\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=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p9\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main( )\n{\n\n \/\/ Declaring variable n=to store the entered number by user\n int n; \n\n \/* Declaring variable r=reverse to store the reverse of a number, \n s=sum 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=rev(n);\n \n \/\/ Displaying reverse number\n printf(\"Reverse of a number = %d\",r);\n \n \/\/ Calling function add\n s=add(n,r); \n \n \/\/ Displaying result or sum\n printf(\"\\nSum of a given and reverse number = %d\",s);\n \n getch( ); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n }\n \n int rev( int n)\n {\n  \/* Declaring variable d=digit to store the extracted digit, \n  rev=reverse to store reversed number *\/\n  int d,rev=0;\n  \n  while(n\u0026gt;0)\n  {\n   d=n%10;\n   rev=rev*10+d;\n   n=n\/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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"functions"}],"title":{"type":"text","$t":"C PROGRAMS : FUNCTION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : FUNCTION\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p1\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p2\" name=\"p2\"\u003E2. Program to print the area of a rectangle \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nvoid area()\n{\n \/\/ Declaring variable l=length, b = 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 = %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=\"color: blue;\"\u003E getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p3\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=0;\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 = factorial(n1);\n f2 = factorial(n2);\n \n \/\/ Calculating sum and displaying result\n sum = f1 + f2;\n\n printf(\"Factorial of first number %d = %d \\n\", n1, f1);\n printf(\"Factorial of second number %d = %d \\n\", n2, f2);\n printf(\"Sum of factorial of two numbers %d and %d = %d \",n1, n2, sum);\n  \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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=1;\n \n \/\/ Calculating factorial\n for(i=1;i\u0026lt;=n;i++)\n {\n  fact = 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=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p4\" name=\"p4\"\u003E4. Program to implement functions that returns HCF OR GCD and LCM of two numbers \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=1;\n \n for(i=1; i\u0026lt;=x;i++)\n {\n  if(x%i==0 \u0026amp;\u0026amp; y%i==0)\n  {\n   hcf=i;\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=1;\n \n \/\/ lcm is calculated by formula : hcf * lcm =1\n lcm = (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=to hold hcf returned to it, \n lcm=to 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=calculatehcf(a, b);\n \n \/\/ Calling function calculatelcm\n lcm=calculatelcm(a, b, hcf);\n \n \/\/ Printing hcf and lcm\n printf(\"hcf = %d \",hcf);\n printf(\"\\nlcm = %d \",lcm);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p5\" name=\"p5\"\u003E5. Implement a function that takes two values of integer type and interchange them \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nvoid swap_without_third_variable(int a, int b)\n{\n \/\/ performing swapping\n a=a+b;\n b=a-b;\n a=a-b;\n \n \/\/ Printing interchange value\n printf(\"\\nInterchange value without use of third variable : a=%d, b=%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=a;\n a=b;\n b=swap;\n \n \/\/ Printing interchange value\n printf(\"\\nInterchange value without use of third variable : a=%d, b=%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 = %d, b = %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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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":"functions"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Learn C"}],"title":{"type":"text","$t":"COMMON PROGRAMMING ERROR - FUNCTION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Cdiv style=\"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=\"http:\/\/www.comp-psyche.com\/2013\/11\/common-programming-error-complete-list.html\" target=\"_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=\"color: lime;\"\u003Edouble x,y\u003C\/span\u003E instead of \u003Cspan style=\"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=\"text-align: justify;\"\u003E\u003Cspan style=\"color: yellow;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;For example:\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;float division(float a, int b); \u0026nbsp;\/\/ error\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; {\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; return a\/b;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; }\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"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=\"text-align: justify;\"\u003E\u003Cspan style=\"color: yellow;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;For example:\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;float division(float a, int b)\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; {\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"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=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; }\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"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=\"text-align: justify;\"\u003E\u003Cspan style=\"color: yellow;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; For example:\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; float division(float a, int b)\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;{\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; return ;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cspan style=\"color: lime;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\u003Cdiv\u003E\u003Cspan style=\"color: yellow;\"\u003EMore Informative Posts:\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cul\u003E\u003Cli\u003E\u003Cspan style=\"color: yellow;\"\u003E\u003Ca href=\"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=\"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=\"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=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}}]}});