[ create a new paste ] login | about

Link: http://codepad.org/ebgG6i9e    [ raw code | output | fork | 2 comments ]

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
posted by dangtiendat86@gmail.com on Feb 5
#include<iostream>
using namespace std;
main(){
int n;
cout<<"n=";
cin>>n;
float s=1;
for (int i=1; i<=n; i++){
s=1.0/(s+1);
}
cout<<"kq="<<s<<endl;
}
reply