[ create a new paste ] login | about

Link: http://codepad.org/ebgG6i9e    [ raw code | output | fork | 1 comment ]

C, pasted on Aug 21:
#include<stdio.h>
#include<conio.h>

int main()
{
	int i, n;
	float S;
	i = 0;
	S = 1;

	printf("\nNhap n: ");
	scanf("%d", &n);

	while(i <= n)
	{
	  S = 1 + 1.0/S;
	  i++;
	}
	printf("\nTong la %f", S);
	getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by kendypham on Nov 15
#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()
{
int n,i;
float s = 0;
printf("Nhap vao n : ");
scanf("%d", &n);
for ( i = 1; i <= n; i++)
s = 1 / (1 + s);
printf("S(n) = %f", s);
getch();
}
reply