C programming

Showing posts with label c program to calculate square. Show all posts
Showing posts with label c program to calculate square. Show all posts

Friday, April 8, 2016

C program to calculate square of a number using recursive function

#include<stdio.h>
int square(int f)
 {
  static int count=0;
  count++;
  printf("%d ",count);
  if(f==1||(count==f))
   return f;
  else
   return (f+square(f));
 }
void main()
{
 int n=4;
 int j=square(n);
 printf("square=%d",j);
}

output
square=16
Posted by Dinesh Agrawal at 8:09 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: c program to calculate square, c program to calculate square using recursive function, calculate square, function in c, recursion, recursion in c, recursive function
Older Posts Home
Subscribe to: Posts (Atom)

About Me

My photo
Dinesh Agrawal
View my complete profile

Blog Archive

  • ▼  2016 (61)
    • ▼  June (9)
      • C program to understand the concept of initializat...
      • C program to make two matrix dynamically and show ...
      • C program to calculate GCD (greatest common diviso...
      • C program to save and retrieve records from extern...
      • c program to find factorial of a number without us...
      • C program to select elements from three given arra...
      • c++ program to show operation on time, add seconds...
      • C program to check given number in strong number o...
      • c program to count number of 1 in binary represent...
    • ►  May (14)
    • ►  April (15)
    • ►  March (23)
Simple theme. Theme images by fpm. Powered by Blogger.