Sunday, 20 September 2015

Que1)Print 35,34,31,22,-5

void series1()
{
   int k=35,i=3,n=5,j;
   printf("Output1:\n");
   //printf("%f",pow(i,n));
   printf("%d,\t",k);
  
   for(j=0;j<n;j++)
   {
      k=k-pow(i,j);
      printf("%d,\t",k);
   }  
   printf("\n");
}

/* Note: How we compile this code in gcc:-
You need to compile with the flag -lm, like this:
gcc series.c -lm -o series
This will tell gcc to link your code against the math lib.
Just be sure to put the flag after the objects you want to link.
*/

No comments:

Post a Comment