TechEnclave
Register Now

Registration is free.
Join us today.

Post ur C/C++ Programs Here

This is a discussion on Post ur C/C++ Programs Here within the Programming forums, part of the General Computing category; Hey guys, If you are a good at C/C++ Programming or if you are a programmer or just know ...

TechEnclave > General Computing > Programming


Reply
 
LinkBack Thread Tools Display Modes
  #1   mavihs's Rig  
Old 7 Oct 08, 04:23 PM
mavihs's Avatar
Hyperactive Member
 
Join Date: Jun 2008
Location: Cyber World
Posts: 90
mavihs is Mysterious
Default Post ur C/C++ Programs Here

Hey guys,

If you are a good at C/C++ Programming or if you are a programmer or just know this language then post you Programs here. By this way it helps learners a lot. Members can post their programs and get suggestions if there is anything wrong it.

Reply With Quote
  #2   Keane 16's Rig  
Old 7 Oct 08, 04:27 PM
Keane 16's Avatar
Explosive Member
 
Join Date: Feb 2006
Location: Berkeley, CA
Age: 18
Posts: 2,893
Keane 16 is highly ReputableKeane 16 is highly ReputableKeane 16 is highly ReputableKeane 16 is highly ReputableKeane 16 is highly ReputableKeane 16 is highly Reputable
Send a message via MSN to Keane 16
Default Re: Post ur C/C++ Programs Here

....Or you could call them your own projects and submit them in school/college.

Reply With Quote
  #3   mavihs's Rig  
Old 7 Oct 08, 05:08 PM
mavihs's Avatar
Hyperactive Member
 
Join Date: Jun 2008
Location: Cyber World
Posts: 90
mavihs is Mysterious
Post Re: Post ur C/C++ Programs Here

Here is 1 from me:

Code:
/*WAP to copy content of one file to another
i) As it is.
ii) After converting all characters to upper case

Name: Shivam*/

#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<stdlib.h>

void main()
{
   clrscr();
   char path1[100], path2[100], ch, ch2;
   int cho;
   cout<<"\n\tEnter the path of the file which has to be copied: ";
   gets (path1);
   ifstream org(path1);
   if(!org)
   {
      cout<<"\tFile not found!";
      exit(0);
   }
   cout<<"Enter the name or the path of the file where the file has to be copied to: ";
   gets(path2);
   ofstream wrt(path2);
   if(!wrt)
   {
      cout<<"\tCannot create file!";
      exit(0);
   }

   cout<<"\t 1. Enter 1 to copy file as it is. \n\t 2. Enter 2 to copy file after converting all lower case characters to upper case characters. \n\n\t Enter your choice: ";
   cin>>cho;
   if(cho==1)
   {
      do{
         org.get(ch);
         wrt.put(ch);
      }while(!org.eof());
   }
   else
   {
      if(cho==2)
      {
         do{
            org.get(ch);
            if(ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f' || ch == 'g' || ch == 'h' || ch == 'i' || ch == 'j' || ch == 'k' || ch == 'l' || ch == 'm' || ch == 'n' || ch == 'o' || ch == 'p' || ch == 'q' || ch == 'r' || ch == 's' || ch == 't' || ch == 'u' || ch == 'v' || ch == 'w' || ch == 'x' || ch == 'y' || ch == 'z')
            {
               ch2 = ch - 32;
               wrt.put(ch2);
            }
            else
            wrt.put(ch);
            
         }while(!org.eof());
      }
      else
      cout<<"Wrong choice entered!";
   }
}

Reply With Quote
  #4   VanishingNerd's Rig  
Old 7 Oct 08, 05:11 PM
VanishingNerd's Avatar
Overloaded Member
 
Join Date: Oct 2006
Location: Bangalore
Age: 22
Posts: 594
VanishingNerd is NotableVanishingNerd is Notable
Send a message via MSN to VanishingNerd Send a message via Skype™ to VanishingNerd
Default Re: Post ur C/C++ Programs Here

Umm why this??
if(ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f' || ch == 'g' || ch == 'h' || ch == 'i' || ch == 'j' || ch == 'k' || ch == 'l' || ch == 'm' || ch == 'n' || ch == 'o' || ch == 'p' || ch == 'q' || ch == 'r' || ch == 's' || ch == 't' || ch == 'u' || ch == 'v' || ch == 'w' || ch == 'x' || ch == 'y' || ch == 'z')

why not ch > 96 && ch <123 ??

Reply With Quote
  #5   H@cKer's Rig  
Old 7 Oct 08, 05:13 PM
H@cKer's Avatar
Overloaded Member
 
Join Date: Feb 2008
Location: Mumbai
Age: 17
Posts: 985
H@cKer is very RespectableH@cKer is very RespectableH@cKer is very RespectableH@cKer is very Respectable
Default Re: Post ur C/C++ Programs Here

View Post
Originally Posted by VanishingNerd
Umm why this??
if(ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f' || ch == 'g' || ch == 'h' || ch == 'i' || ch == 'j' || ch == 'k' || ch == 'l' || ch == 'm' || ch == 'n' || ch == 'o' || ch == 'p' || ch == 'q' || ch == 'r' || ch == 's' || ch == 't' || ch == 'u' || ch == 'v' || ch == 'w' || ch == 'x' || ch == 'y' || ch == 'z')

why not ch > 96 && ch <123 ??
as he is also learning every one has its own way of writing a program.

Reply With Quote
  #6  
Old 7 Oct 08, 05:24 PM
Junior Member
 
Join Date: Sep 2006
Posts: 49
pr0ing is Notable
Default Re: Post ur C/C++ Programs Here

this is not my program

Code:
main(argc, argv)
int	argc;
char	**argv;
{
	while (*argv != argv[1] && (*argv = argv[1]) && (argc = 0) || (*++argv
		&& (**argv && ((++argc)[*argv] && (**argv <= argc[*argv] ||
		(**argv += argc[*argv] -= **argv = argc[*argv] - **argv)) &&
		--argv || putchar(**argv) && ++*argv--) || putchar(10))))
		;
}
The inputs get printed character by character in alphabetical order.

Copyright (c) 1988, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.


source http://www.cise.ufl.edu/~manuel/obfuscate/litmaath.hint
Obfuscated C Code

interested people should check out this site
The International Obfuscated C Code Contest

Reply With Quote
  #7   booo's Rig  
Old 7 Oct 08, 06:22 PM
booo's Avatar
Steroids Member
 
Join Date: Mar 2008
Location: Hyderabad
Posts: 304
booo is very Respectablebooo is very Respectablebooo is very Respectable
Default Re: Post ur C/C++ Programs Here

@mahvis: bad bad idea... I agree with keane on this. I have seen many people posting in forums to get their assignment answers. I dont think I would help such people.

btw, can you write the same program that you wrote above without using the if condition?

Reply With Quote
  #8  
Old 7 Oct 08, 07:11 PM
Hyperactive Member
 
Join Date: Aug 2007
Posts: 62
cool1 is Mysterious
Default Re: Post ur C/C++ Programs Here

any 1 knows program floyd's triangle using c#
for this
1
23
456
78910

and for this too
1
01
101
0101
10101

Reply With Quote
  #9  
Old 7 Oct 08, 09:31 PM
Fanatic Member
 
Join Date: Nov 2007
Posts: 175
iq6886 is somewhat of a mystery
Default Re: Post ur C/C++ Programs Here

@cool1: yes i know both of them , but won't share the code.. rather i can give u some hint how to do it.
u can do both using 2 loops only.. give it a shot and get back with what u tried...

Reply With Quote
  #10  
Old 7 Oct 08, 11:49 PM
Yamaraj's Avatar
Steroids Member
 
Join Date: Aug 2005
Location: New Delhi
Posts: 389
Yamaraj is highly ReputableYamaraj is highly ReputableYamaraj is highly ReputableYamaraj is highly ReputableYamaraj is highly ReputableYamaraj is highly Reputable
Send a message via MSN to Yamaraj Send a message via Yahoo to Yamaraj
Default Re: Post ur C/C++ Programs Here

View Post
Originally Posted by VanishingNerd
Umm why this??
why not ch > 96 && ch <123 ??
Umm why this??
Why not (ch >= 'a' && ch <= 'z')??

You're familiar with the hazards of using magic numbers and non-portable character sets, aren't you? (Hint: ASCII and EBCDIC)

Reply With Quote
  #11   mavihs's Rig  
Old 8 Oct 08, 12:22 AM
mavihs's Avatar
Hyperactive Member
 
Join Date: Jun 2008
Location: Cyber World
Posts: 90
mavihs is Mysterious
Post Re: Post ur C/C++ Programs Here

View Post
Originally Posted by VanishingNerd
Umm why this??
if(ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f' || ch == 'g' || ch == 'h' || ch == 'i' || ch == 'j' || ch == 'k' || ch == 'l' || ch == 'm' || ch == 'n' || ch == 'o' || ch == 'p' || ch == 'q' || ch == 'r' || ch == 's' || ch == 't' || ch == 'u' || ch == 'v' || ch == 'w' || ch == 'x' || ch == 'y' || ch == 'z')

why not ch > 96 && ch <123 ??
DAnM !!!! y didn't it get into my mind, it took me a long time 2 write this.!!! thanx!!!!

View Post
Originally Posted by H@cKer
as he is also learning every one has its own way of writing a program.
+1
thats y i've put this tread so ppl can learn from seeing other prgs & also ppl can help existing 1's!!!
View Post
Originally Posted by booo
@mahvis: bad bad idea... I agree with keane on this. I have seen many people posting in forums to get their assignment answers. I dont think I would help such people.

btw, can you write the same program that you wrote above without using the if condition?
there r similar threads in other forum also. we can all post already made prgs & ask for help in improving existing 1's but doing other ppls assignment won't be done!!!

i think i can write without if hopefully!!! i did this prg for my skool so also posted it here.

View Post
Originally Posted by Yamaraj
Umm why this??
Why not (ch >= 'a' && ch <= 'z')??

You're familiar with the hazards of using magic numbers and non-portable character sets, aren't you? (Hint: ASCII and EBCDIC)
i'm confused about this part. will it work????
View Post
Originally Posted by cool1
any 1 knows program floyd's triangle using c#
for this
1
no projects will be entertained here!!!! if u complete this prg on ur own then u can post it here or if u want a bit help u can ask for help!!!

Reply With Quote
  #12  
Old 8 Oct 08, 08:34 AM
viridian's Avatar
Hyperactive Member
 
Join Date: Jun 2008
Location: Bangalore
Posts: 133
viridian is very Notableviridian is very Notableviridian is very Notable
Send a message via MSN to viridian
Default Re: Post ur C/C++ Programs Here

From

Hello World ! - GNU Project - Free Software Foundation (FSF)

#include <iostream.h>
#include <string.h>
class string
{
private:
int size;
char *ptr;
public:
string() : size(0), ptr(new char('\0')) {}
string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}
~string()
{
delete [] ptr;
}
friend ostream &operator <<(ostream &, const string &);
string &operator=(const char *);
};

ostream &operator<<(ostream &stream, const string &s)
{
return(stream << s.ptr);
}
string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}
int main()
{
string str;
str = "Hello World";
cout << str << endl;
return(0);
}

Reply With Quote
  #13  
Old 8 Oct 08, 09:23 AM
hammerhead's Avatar
Overloaded Member
Member of the Month for July2008
 
Join Date: Jun 2006
Location: Noida
Age: 22
Posts: 533
hammerhead is highly Admirablehammerhead is highly Admirablehammerhead is highly Admirablehammerhead is highly Admirablehammerhead is highly Admirablehammerhead is highly Admirablehammerhead is highly Admirablehammerhead is highly Admirable
Default Re: Post ur C/C++ Programs Here

Bad bad idea. Keane's right.

Reply With Quote
  #14   mavihs's Rig  
Old 8 Oct 08, 12:52 PM
mavihs's Avatar
Hyperactive Member
 
Join Date: Jun 2008
Location: Cyber World
Posts: 90
mavihs is Mysterious
Default Re: Post ur C/C++ Programs Here

View Post
Originally Posted by hammerhead
Bad bad idea. Keane's right.
every1 has here own views!!! u feel its not right, i feel its right.
View Post
Originally Posted by viridian
From

Hello World ! - GNU Project - Free Software Foundation (FSF)

#include <iostream.h>
#include <string.h>
class string
{
private:
int size;
char *ptr;
public:
string() : size(0), ptr(new char('\0')) {}
string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}
~string()
{
delete [] ptr;
}
friend ostream &operator <<(ostream &, const string &);
string &operator=(const char *);
};

ostream &operator<<(ostream &stream, const string &s)
{
return(stream << s.ptr);
}
string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}
int main()
{
string str;
str = "Hello World";
cout << str << endl;
return(0);
}
wat does this do????

Reply With Quote
  #15  
Old 8 Oct 08, 02:28 PM
Junior Member
 
Join Date: Sep 2006
Posts: 49
pr0ing is Notable
Default Re: Post ur C/C++ Programs Here

View Post
Originally Posted by mavihs
wat does this do????
its the Hello World Program.
prints 'Hello World' as output.

Reply With Quote
Reply


Thread Tools
Display Modes


Welcome, Unregistered.

  
Search
Advertisement


From FunEnclave
Quick Navigation

All times are GMT +5.5. The time now is 06:35 PM.


Style by Safin, exclusive for TechEnclave
Copyright ©2005 - 2008 TechEnclave.com, All Rights Reserved.
Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0