Pages

Wednesday, 25 January 2017

function to print the series

NIELIT O Level
C Language Paper 
January-16
Question no: (6.b)

Write a function to print the sum of the following series:
                               1 + 22 + 33 + … + nn

Solution : 



/*   ################################
     Girfa Student Help
     Function for series printing
     for more visit : http://girfahelp.blogspot.in/p/c-language.html
     ################################
*/
#include<stdio.h>
#include<conio.h>
int sr(int);
void main()

{
     int n;
     clrscr();
     printf("enter number>> ");
     scanf("%d",&n);
     sr(n);
     getch();
}

int sr(int n)
{
     int m;
     printf("\n\t1");
     for(m=22;m<=n;m=m+11)
           printf(" %d,",m);;
}

No comments:

Post a Comment