SHARE
TWEET

task2

Mary_99 Jan 22nd, 2019 15 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.     int n=2;
  9.     int Xn;
  10.     int i, j;
  11.     int E; //epsilon
  12.     int a[100];
  13.     i = 0;
  14.     printf("Enter the E: ");
  15.     scanf(" %d", &E);
  16.     printf("%d\n", 2);
  17.    
  18.     do
  19.     {
  20.         a[0]=2;
  21.         a[1]=5;
  22.         Xn=2*a[n-2]+a[n-1];
  23.         a[n]=Xn;
  24.         for(i=0;i<n;i++)
  25.         {
  26.             printf("%d ", a[i]);
  27.         }
  28.         n++;
  29.         printf("\n");
  30.              
  31.     }
  32.             while(Xn<E);
  33.    
  34.  
  35.     return 0;
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top