hey i found out the vale of pie in a special way.
i think it is interesting
i am expecting some comments on this.

#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	int n[10000];
	int i,p=1,c=1;
	for (i=0;i<10000;i++)
	{  if(p<7)
	   p=p*10;
	   n[i]=char(p/7);
	   p=p%7;
	}
	cout<<3<<" . ";
	for (i=0;i<10000;i++,c++)
	{   if(c==1800)
	    {   getch();
		clrscr();
		c=1;
	    }
	    cout<<n[i];
	}
	getch();
}

Also: #include<iostream.h> -- old header that shouldn't be used for the past umpteen years #include<conio.h> -- header that should not be used as it's not portable void main() -- main() has NEVER been a void, always an int, see this clrscr(); -- useless function only defined in 1 old compiler, no other compiler has it. getch(); -- another function that should be avoided, only a couple compilers have defined it.

"void main() -- main() has NEVER been a void, always an int, see this"

But I beg to differ a bit - once upon a time main( ) was a void function. Read K&R recently? The earliest C++ book I have, circa 1993, uses the form

main ( )
{
   //code here
}

I agree, it is now an incorrect form, and the reasons given in the several articles linked at the gidnetwork article are quite extensive. But let's not go about rewriting history. That's for the politicians.

Val

"void main() -- main() has NEVER been a void, always an int, see this"

But I beg to differ a bit - once upon a time main( ) was a void function. Read K&R recently? The earliest C++ book I have, circa 1993, uses the form

main ( )
{
   //code here
}

not really. in C, a missing type defaults to an 'int'. and control reaching the end of a non-void function is at most a warning, not an error. even in the oldest K&R, you would not see

void main ( )
{
   //code here
}

here is an example:

foo()
{ return 5 ; } /* warning: return type defaults to `int' */

void bar()
{ return 5 ; } /* warning: `return' with a value, in function returning void */

int foobar() {}

main() /* warning: return type defaults to `int' */
{
  int (*pfn1)() = &foo ;
  void (*pfn2)() = &foo ; /* warning: initialization from incompatible pointer type */
}

/**
*****************  gcc 4.2.3 20071024 *********************
>gcc -std=c89 -Wall -Wreturn-type -pedantic -Werror -c cmain.c
cc1: warnings being treated as errors
cmain.c:2: warning: return type defaults to 'int'
cmain.c: In function 'bar':
cmain.c:5: warning: 'return' with a value, in function returning void
cmain.c: In function 'foobar':
cmain.c:7: warning: control reaches end of non-void function
cmain.c: At top level:
cmain.c:10: warning: return type defaults to 'int'
cmain.c: In function 'main':
cmain.c:12: warning: initialization from incompatible pointer type
cmain.c:12: warning: unused variable 'pfn2'
cmain.c:11: warning: unused variable 'pfn1'
cmain.c:13: warning: control reaches end of non-void function

*****************  gcc 4.2.3 20071024 *********************
>gcc -std=c89 -Wall -Wreturn-type -pedantic-errors -Werror -c cmain.c
cc1: warnings being treated as errors
cmain.c:2: warning: return type defaults to 'int'
cmain.c: In function 'bar':
cmain.c:5: error: 'return' with a value, in function returning void
cmain.c: In function 'foobar':
cmain.c:7: warning: control reaches end of non-void function
cmain.c: At top level:
cmain.c:10: warning: return type defaults to 'int'
cmain.c: In function 'main':
cmain.c:12: error: initialization from incompatible pointer type
cmain.c:12: warning: unused variable 'pfn2'
cmain.c:11: warning: unused variable 'pfn1'
cmain.c:13: warning: control reaches end of non-void function

*****************  microsoft vc++ 8.0 *********************
>cl /O2 /GL /D "WIN32" /D "_CONSOLE" /FD /MD /Za /Wall /WX /c /Zi /TC /c cmain.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved. 
cmain.c
cmain.c(1) : error C2220: warning treated as error - no 'object' file generated
cmain.c(1) : warning C4255: 'foo' : no function prototype given: converting '()' to '(void)' 
cmain.c(2) : warning C4431: missing type specifier - int assumed. Note: C no longer supports default-int
cmain.c(4) : warning C4255: 'bar' : no function prototype given: converting '()' to '(void)' 
cmain.c(5) : warning C4098: 'bar' : 'void' function returning a value
cmain.c(7) : warning C4255: 'foobar' : no function prototype given: converting '()' to '(void)'
cmain.c (9) : warning C4255: 'main' : no function prototype given: converting '()' to '(void)'
cmain.c(10) : warning C4431: missing type specifier - int assumed. Note: C no longer supports default-int
cmain.c(11) : warning C4255: 'pfn1' : no function prototype given: converting '()' to '(void)'
cmain.c(12) : warning C4255: 'pfn2' : no function prototype given: converting '()' to '(void)' 
cmain.c(12) : warning C4189: 'pfn2' : local variable is initialized but not referenced
cmain.c(11) : warning C4189: 'pfn1' : local variable is initialized but not referenced
*/
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.