Post your C/C++ Programs Here

Status
Not open for further replies.
Re: Post ur C/C++ Programs Here

here is a link to a simple prog i made in my school days ..have a look.

Its an EXE file, but not a virus or anything like that.

here is the Link
 

ambika

learnhardy
Re: Post ur C/C++ Programs Here

I am very comfortable with TURBO C or C++........now just i m shifted to dev C++(beta version),geany etc .......in my new linux system .....i have been facing problem with these compilers ......can u guys simplly tell me whts the main difference between these two ........how to set these compilers in linux??
 

sankha

Right off the assembly line
Re: Post ur C/C++ Programs Here

I have a full banking software written in C++. But it's hard to copy here as it's more than 10,000 lines of code. If anybody needs it please contact me.










_________________________________
Protect personal data
 

shirishsriv

Right off the assembly line
Re: Post ur C/C++ Programs Here

scanf("%d%d%d",&a,&b,&c);
New to c++.......Whta those this line means
these lines says that
your integer values will be saved in the block of variable a,b&c.

Can anybody tell me the program of snake game without use of pointers And with use of pointers??????
 
Last edited:

happy20b

Journeyman
Re: Post ur C/C++ Programs Here

I Have written a code which will take number between 0 to 99,99,99,999 and will print in words..
this code i had written 4 years back..
eg:
input : 22812
output: twenty two thousand eight hundred and twelve

I had written TicTc game in TurboC C with mouse interface
And also solution for Sudoku game (Worst part is giving input :) )
 

╬Switch╬

In the zone
Re: Post ur C/C++ Programs Here

Does anyone know what return0 does and also why is it necessary to have "void main" and getch()?
 

Sykora

I see right through you.
Re: Post ur C/C++ Programs Here

"void main" is _wrong_. "getch()" is _not_ necessary.

main() is literally the program's main function. The OS uses the return value of a program to determine whether it exited properly or not. Using void main will return a trash value, leaving the OS to guess on its own. Therefore, all your programs _must_ be declared as "int main". Decent compilers will error out on this issue.

Using "return 0" at the end of main() (or any functioni, for that matter) will return the value 0 to the calling function. In main, this value is returned to the OS, where a return value of 0 indicates execution success. This way the OS can properly tell what happened after the fact.

getch() is a Borland-specific hack to get the output to wait for the user's keypress before continuing. It is non-portable, non-standard, and too damn old. Use a better compiler.
 

QwertyManiac

Commander in Chief
Re: Post ur C/C++ Programs Here

Aren't we getting tired of answering the very same questions every week of the month in this section? We need some sort of a Read-This-First thread with a FAQ.
 

Liverpool_fan

Sami Hyypiä, LFC legend
Re: Post ur C/C++ Programs Here

^ I agree. There must be an FAQ which links to FAQ of many programming languages particularly C/C++ and also other languages answering this recurring questions.
 

thinkme

Right off the assembly line
Re: Post ur C/C++ Programs Here

Hey guys,,

come on i've got something to ask u all??


1. What will be the output of:
int main()
{ int a=5;
printf("%d",printf("%f",a));
}

2. What are command line arguments? How to use them??
I know a bit abt it. If someone knows it better plz share here...

3. How is VAriable Argument list used.. Plz explain with a good xample.
 

mehulved

18 Till I Die............
Re: Post ur C/C++ Programs Here

Hey guys,,

come on i've got something to ask u all??


1. What will be the output of:
int main()
{ int a=5;
printf("%d",printf("%f",a));
}
Try it?
Compiler throws me warnings and returns garbage values.

2. What are command line arguments? How to use them??
I know a bit abt it. If someone knows it better plz share here...
Unless you tell what you know about. Why should someone take the pain of explaining, when you don't do the same.

3. How is VAriable Argument list used.. Plz explain with a good xample.
Loads on examples on this if you search for it.
 

Liverpool_fan

Sami Hyypiä, LFC legend
Re: Post ur C/C++ Programs Here

*www.cplusplus.com/reference/clibrary/cstdio/printf.html
Return Value
On success, the total number of characters written is returned.
On failure, a negative number is returned.

But it would throw only a garbage value in this case...
 
Last edited:

happy20b

Journeyman
Re: Post ur C/C++ Programs Here

Hey guys,,

come on i've got something to ask u all??


1. What will be the output of:
int main()
{ int a=5;
printf("%d",printf("%f",a));
}
output wil be garbage but you would hav asked for reason instead of the output

the outputs which i got were
-0.8992659
-0.0196369
-0.0340909
and you can see number 9 at the end of each output an that is the output of printf("%d", and the rest out put is of printf("%f",a) acttualy if you use \n in 2nd printf
like
printf("%d",printf("%f\n",a));
you should be able to see output somthing like

-0.039340 printf("%f\n",a)
10 printf("%d"

since you are printing an integer value in float format internal conversion will make output something like -0.019636 (garbage) and then second printf will print the return value of first printf ie number of characters it printed ie in above case it is 9 characters hence output will be -0.0196369




2. What are command line arguments? How to use them??
I know a bit abt it. If someone knows it better plz share here...

It is the way of passing arguments to main function ..

main(int argc, char *argv[])

so you can pass arguments to this main function at command promt
promt$ ./program hello 3 name
argv[0] argv[1] argv[2] argv[3]

so main will get 4 arguments as above .. and argc will be 4


3. How is VAriable Argument list used.. Plz explain with a good xample.

you mean to say variable argument in functions ???
 
Last edited:
Re: Post ur C/C++ Programs Here

This may sound stupid.
I want to set up an editor+compiler to type out C/C++ programs
Most places I've been use Turbo C
But after searching on the net, I found that it's old and only trial version is available.
I downloaded and installed Relo
Sadly since I dont have a complier (atleast that's what it seems like), I dont know what to do here on.
Any compilers I should download? If so which one? How?
 
Status
Not open for further replies.
Top Bottom