To print series using function in C


Levels of difficulty: / perform operation:

C program to print the following series using function.

9 25 57 121 249 505 1017 2041…

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	int num=9,i;
	clrscr();
	printf("%d ",num);
	for(i=4;i<=10;i++)
	{
		num=num+pow(2,i);
		printf("%d ",num);
	}
	getch();
}
pow(int a,int b)
{
	int prod=1,j;
	for(j=1;j<=b;j++)
		prod=prod*a;
	return(prod);
}


Output







Quantitative Aptitude
Reasoning
Programming
Interview