Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack (1) Thread Tools Display Modes
Old 26-09-2011, 11:24 PM   #721 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: Post your C/C++ Programs Here


Quote:
Originally Posted by vickybat View Post
Suggest me what to do mate??
Try Geany. Make sure your paths are configured, and g++ and gcc works from the command line.

Quote:
Originally Posted by vickybat View Post
Oh got it mate. Thanks for that. I will modify the code accordingly.

I guess a switch case to check vowels will do isn't it?
And to do that we have to check each and every character of the string.
Loops will also be needed.
STL will make it much simpler. (Not necessarily most efficient).
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 27-09-2011, 11:36 AM   #722 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

@ neuron

sorry buddy actually i was on the wrong path......thnx for making me realise the actual piglatin concept. I will too try my level best to write on the way u told...........

one more help can u plz check out the bubble sort program of mine mentioned earlier and write me the same using recursion......
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 27-09-2011, 03:41 PM   #723 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: Post your C/C++ Programs Here

Quote:
Originally Posted by somulesnar View Post
@ neuron
one more help can u plz check out the bubble sort program of mine mentioned earlier and write me the same using recursion......
You should not ask someone else to write a program for you if you want to "learn" programming.
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 27-09-2011, 08:52 PM   #724 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

^^ buddy i have already mentioned that i am a novice in c c++ programming language.

Yet if i am wrong then plz atleast plz suggest me the logic that i shud use for the stated program...
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 27-09-2011, 11:23 PM   #725 (permalink)
127.0.0.1
 
mitraark's Avatar
 
Join Date: Nov 2010
Location: Kolkata / Durgapur
Posts: 769
Default Re: Post your C/C++ Programs Here

Quote:
Originally Posted by somulesnar View Post
^^ buddy i have already mentioned that i am a novice in c c++ programming language.

Yet if i am wrong then plz atleast plz suggest me the logic that i shud use for the stated program...
I know this might feel a little harsh but never try to get your homework done from Net instead if you go through the book trying to find the answer you;ll leanr not only that but many other important things as well.

Since you are trying to get Bubble Sort using recursion , you can definitely start to read up on "Recursion" chapter in the C / C++ Book you got.
__________________
Intel i5 760 || Gigabyte H55 || Corsair 4GB 1333MHz Value || XFX HD5670 1GB
WD 2TB Green + Seagate 5900RPM 2 TB + Seagate Freeagent 1 TB x2
Corsair CX400 || Zebronics Bijli || Samsung P2350 23.5" || Altec Lansing VS2621
My Speedtest :D
mitraark is online now  
Old 28-09-2011, 10:23 AM   #726 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: Post your C/C++ Programs Here

A bit offtopic, but I found this site interesting - Computational Fairy Tales: Posts by Topic

It teaches algorithm like a fairy tales.

And this site visualize the different sorting algorithms - Sorting Algorithm Animations
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 28-09-2011, 07:08 PM   #727 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

Quote:
Originally Posted by mitraark View Post
I know this might feel a little harsh but never try to get your homework done from Net instead if you go through the book trying to find the answer you;ll leanr not only that but many other important things as well.

Since you are trying to get Bubble Sort using recursion , you can definitely start to read up on "Recursion" chapter in the C / C++ Book you got.

@ mitraark

if i wud rely mostly on books then for what is this thread made for. It is made for the learners in c and c++ programmers. So if u have learned enough of it then my kind request to u is to plz stop posting unnecessary posts into it. If u r not willing to help then its well and fine.

BTW i didnt ask my prob to u personally i asked to the members who are willing to help me with my prob. So plz stop commenting on others posts.....
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 28-09-2011, 08:33 PM   #728 (permalink)
127.0.0.1
 
mitraark's Avatar
 
Join Date: Nov 2010
Location: Kolkata / Durgapur
Posts: 769
Default Re: Post your C/C++ Programs Here

Quote:
Originally Posted by somulesnar View Post
@ mitraark

if i wud rely mostly on books then for what is this thread made for. It is made for the learners in c and c++ programmers. So if u have learned enough of it then my kind request to u is to plz stop posting unnecessary posts into it. If u r not willing to help then its well and fine.

BTW i didnt ask my prob to u personally i asked to the members who are willing to help me with my prob. So plz stop commenting on others posts.....
I am sorry but i did not mean to have offended you in any way. It is just that the problem you presented is a textbook problem of recursion , probably every book out there that covers Recursion has the answers as an example. So i thought maybe a book will come in handy for you
__________________
Intel i5 760 || Gigabyte H55 || Corsair 4GB 1333MHz Value || XFX HD5670 1GB
WD 2TB Green + Seagate 5900RPM 2 TB + Seagate Freeagent 1 TB x2
Corsair CX400 || Zebronics Bijli || Samsung P2350 23.5" || Altec Lansing VS2621
My Speedtest :D
mitraark is online now  
Old 28-09-2011, 08:36 PM   #729 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

^^ its alright buddy. Actually ur post started of with an irritating take off. U r right in ur point but the thing is that i am on the go so i dont have any books on with me so plz co-operate.
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 28-09-2011, 08:37 PM   #730 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: Post your C/C++ Programs Here

You don't have books, but you can always google.
Anyway your problem is with recursion concept and just this problem?
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline  
Old 28-09-2011, 08:45 PM   #731 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

^^ yes of course i searched a lot of sites but cant get a proper one for the above program....

All the codes are written in the sites in more or less C++ language wich i am not friendly with. So plz help..
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 28-09-2011, 09:13 PM   #732 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Cool Re: Post your C/C++ Programs Here

Quote:
Originally Posted by somulesnar View Post
@ mitraark

if i wud rely mostly on books then for what is this thread made for. It is made for the learners in c and c++ programmers. So if u have learned enough of it then my kind request to u is to plz stop posting unnecessary posts into it. If u r not willing to help then its well and fine.

BTW i didnt ask my prob to u personally i asked to the members who are willing to help me with my prob. So plz stop commenting on others posts.....
Mind you, this thread is NOT made for asking to solve your homework questions directly, without even reading books or searching Google.
People who ask for help without even trying are not *learners*.
I would say, this is a very bad attitude towards learning and towards the community.

And I think you need to read through following link BEFORE you ask any more questions. It would help you in your online stay.

How To Ask Questions The Smart Way

Quote:
Before asking a technical question by e-mail, or in a newsgroup, or on a website chat board, do the following:
  • Try to find an answer by searching the archives of the forum you plan to post to.
  • Try to find an answer by searching the Web.
  • Try to find an answer by reading the manual.
  • Try to find an answer by reading a FAQ.
  • Try to find an answer by inspection or experimentation.
  • Try to find an answer by asking a skilled friend.
  • If you're a programmer, try to find an answer by reading the source code.
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 28-09-2011, 09:37 PM   #733 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

^^ ok fine i ll first try to sort out tjis question wen i return home then ill post in this thread... till then good bye TDF members....
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 28-09-2011, 09:54 PM   #734 (permalink)
Super Moderator
 
asingh's Avatar
 
Join Date: May 2008
Location: New Delhi
Posts: 5,548
Default Re: Post your C/C++ Programs Here

Guys....have we gone nuts in the head or what...? How can you ascertain that it is homework which is being requested here. And if it is..? So..? The world has changed, if a problem is assigned to a student the teacher know quite well that external sources can be looked upon. Day of reckoning comes when the person takes a test behind 4 walls.

So let us not be so condescending and try to deter members when they ask queries. I personally have created SQL queries and Excel spreadsheets and MDB DB's for users whose handle ID was all I knew..?

If someone does not want to help, they can at least guide or explain a couple of concepts. Somulesnar, started his post with a decent code snippet, so it is not that he is asking TDF to do the work.

Thanks.
__________________
MSI P45 Platinum(BIOS v1.7B)|Q9550[E0]@3.85Ghz@1.320V[453x8.5]MCH@1.184V|ICH@1.55V|DDR_V_Ref_A_B@1.05V|NH-D14|Corsair TWIN2X4096-8500C5(5-5-5-15)@1089Mhz@2.14V
2xHD4890[Xfire]@1000/900[MEM/GPU]|Corsair 650TX|Seagate180GB+80GB+WD1TB|SONY-DVD-R|CM690|2x120mm Scythe Ultra Kaze|DELL S2409W|APC 1100VA|Scythe Kaze Server
Windows 7 Ultimate RTM - 64BIT|Catalyst 10.5 (8.14.10.0753) forced with RadeonPRO|PS3 160GB|Sony 40EX520|AC Ryan POHD Mini|APC 800VA|APC 800VA|D425KT|CM100 Elite|2TB WD|Acer D255

Test your spoiler tags before submitting
asingh is online now  
Old 28-09-2011, 10:01 PM   #735 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: Post your C/C++ Programs Here

somulesnar

Answer this.
Quote:
Originally Posted by Liverpool_fan View Post
Anyway your problem is with recursion concept and just this problem?
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline  
Old 28-09-2011, 10:22 PM   #736 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: Post your C/C++ Programs Here

Quote:
Originally Posted by asingh View Post
Guys....have we gone nuts in the head or what...? How can you ascertain that it is homework which is being requested here. And if it is..? So..? The world has changed, if a problem is assigned to a student the teacher know quite well that external sources can be looked upon. Day of reckoning comes when the person takes a test behind 4 walls.

So let us not be so condescending and try to deter members when they ask queries. I personally have created SQL queries and Excel spreadsheets and MDB DB's for users whose handle ID was all I knew..?

If someone does not want to help, they can at least guide or explain a couple of concepts. Somulesnar, started his post with a decent code snippet, so it is not that he is asking TDF to do the work.

Thanks.
If it would have been *only* about solving the problem and NOT about learning, then I am 100% agree with you. But I am sure, just solving the problem for someone will not help that someone in learning. Will it?
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 28-09-2011, 10:30 PM   #737 (permalink)
Human Spambot
 
Join Date: Nov 2004
Location: Madurai
Posts: 2,349
Default Re: Post your C/C++ Programs Here

^^ Exactly - If the OP posts sample code of what he/she has tried and the problems faced, setting them on the right path helps the OP understand where the mistake is and this transforms the original failure to solve the problem into a learning process. When the OP had earlier asked help in sorting out the piglatin problem, there were useful suggestions given to help the OP in getting to the solution. That is the right way to help the OP learn IMHO...

Arun
sakumar79 is offline  
Old 28-09-2011, 11:01 PM   #738 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

@ asingh

Thnx a lot sir. The same thing i was trying to convey to the other members but i think they didnt get tht perfectly. Anyways i would try to solve this prob myself and if i cant i will let u know guys....

Cheers....

Quote:
Originally Posted by Liverpool_fan View Post
somulesnar

Answer this.

yes my prob is with the recursion concept of this prob only...
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 28-09-2011, 11:27 PM   #739 (permalink)
I am the night! I am....
 
vickybat's Avatar
 
Join Date: Aug 2009
Location: Gotham City
Posts: 4,209
Default Re: Post your C/C++ Programs Here

Quote:
Originally Posted by asingh View Post
Guys....have we gone nuts in the head or what...? How can you ascertain that it is homework which is being requested here. And if it is..? So..? The world has changed, if a problem is assigned to a student the teacher know quite well that external sources can be looked upon. Day of reckoning comes when the person takes a test behind 4 walls.

So let us not be so condescending and try to deter members when they ask queries. I personally have created SQL queries and Excel spreadsheets and MDB DB's for users whose handle ID was all I knew..?

If someone does not want to help, they can at least guide or explain a couple of concepts. Somulesnar, started his post with a decent code snippet, so it is not that he is asking TDF to do the work.

Thanks.
Even i mostly agree to this.
__________________
core i5 750, biostar h55 A+ (X16+X4), 4gb 1333 ddr3, corsair vx450, cm elite 335,Asus EAH 5750 FORMULA , samsung 2033 sw plus, wd green 1tb , wd 1tb my book , hp dvd writer,Apc 650 va, logitech z313
vickybat is offline  
Old 28-09-2011, 11:37 PM   #740 (permalink)
Super Moderator
 
asingh's Avatar
 
Join Date: May 2008
Location: New Delhi
Posts: 5,548
Default Re: Post your C/C++ Programs Here

Quote:
Originally Posted by Garbage View Post
If it would have been *only* about solving the problem and NOT about learning, then I am 100% agree with you. But I am sure, just solving the problem for someone will not help that someone in learning. Will it?
He had posted some code, so telling him what was wrong would help. See if someone has expertise why not tell..?

Quote:
Originally Posted by sakumar79 View Post
^^ Exactly - If the OP posts sample code of what he/she has tried and the problems faced, setting them on the right path helps the OP understand where the mistake is and this transforms the original failure to solve the problem into a learning process. When the OP had earlier asked help in sorting out the piglatin problem, there were useful suggestions given to help the OP in getting to the solution. That is the right way to help the OP learn IMHO...

Arun
If at times someone is not getting it..we can nudge him and give more specific answers. That is how it works...at least I thought so when teaching stuff about programming.
__________________
MSI P45 Platinum(BIOS v1.7B)|Q9550[E0]@3.85Ghz@1.320V[453x8.5]MCH@1.184V|ICH@1.55V|DDR_V_Ref_A_B@1.05V|NH-D14|Corsair TWIN2X4096-8500C5(5-5-5-15)@1089Mhz@2.14V
2xHD4890[Xfire]@1000/900[MEM/GPU]|Corsair 650TX|Seagate180GB+80GB+WD1TB|SONY-DVD-R|CM690|2x120mm Scythe Ultra Kaze|DELL S2409W|APC 1100VA|Scythe Kaze Server
Windows 7 Ultimate RTM - 64BIT|Catalyst 10.5 (8.14.10.0753) forced with RadeonPRO|PS3 160GB|Sony 40EX520|AC Ryan POHD Mini|APC 800VA|APC 800VA|D425KT|CM100 Elite|2TB WD|Acer D255

Test your spoiler tags before submitting
asingh is online now  
Old 29-09-2011, 12:00 AM   #741 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: Post your C/C++ Programs Here

All right.
First of all Bubble Sort is not exactly the most naturally expressed in recursive algorithm. However any iterative algorithm can be made recursive crudely at least. Is the following you desire?

I would still say at least iteratively compare the adjacent items in the function send_max_to_rear, the resulting code stuck with recursion only is very clumsy in my opinion, unless someone does it better.

Spoiler:
PHP Code:

#include <stdio.h>

#define LEN 25

void send_max_to_rear(int *lint posint len); 
void pass(int *lint len); 

int main(void)    {
    
int i;
    
int list[LEN];

    for(
0LEN; ++i)    {
        
printf("Enter for %d: "i+1);
        
scanf("%d", &list[i]);
    }

    
pass(list, LEN);

    for(
0LEN; ++i)    {
        
printf("%d ", list[i]);
    }
    
puts(""); // Put a newline at the end of program's stdin

    
return 0;
}

void send_max_to_rear(int *lint posint len)    {
    
/*
        This function sends the largest member of the sublist to the rear.
    */
    
    /* Compare the members at `pos` and `pos+1` and swap if necessary */
    
if (l[pos] > l[pos+1])    {
        
int temp l[pos];
        
l[pos] = l[pos+1];
        
l[pos+1] = temp;
    }

    
/* As long as there are two elements to compare in the (sub)list, call compare the next two elements. */
    
if (pos len 2)    {
        
send_max_to_rear(lpos+1len); // Move to the next position to compare.
    
}
}

void pass(int *lint len)    {
    
/*
        This function recursively calls unsorted part of the list, after each pass.
    */

    /* As long as array is has two unsorted elements, bubble sort it. */
    
if (len 1    )    {
        
send_max_to_rear(l0len);
        
pass(llen 1);
    }



P.S.: Divide and Conquer based algorithms are more suitable for recursive implementation, I'll suggest try QuickSort.

P.P.S.: Double test the code just in case, sleepy head you know.
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline  
Old 29-09-2011, 08:14 AM   #742 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

^^ thnx a lot. Ok now i got the right logic. Thnx for everything guys.

Cheers...
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 18-10-2011, 10:56 AM   #743 (permalink)
Wise Old Owl
 
clmlbx's Avatar
 
Join Date: Aug 2006
Location: Indore
Posts: 1,687
Default Re: Post your C/C++ Programs Here

Guys, Here is my Programme to calculate Pixel per Inch(ppi) of any screen with Classes in different files.

Code:
// this is main.cpp, actual Programme (Name = main.cpp)

#include <iostream>
#include "PPI.h"

using namespace std;

int main()
{
    PPI ppiobj;
    ppiobj.Welcome();
    ppiobj.GetData();
    ppiobj.Calculateppi();
    ppiobj.Output();

}

Code:

// this is class File/self made header File./ where everything is Declared (Name is = PPI.h)


#ifndef PPI_H
#define PPI_H


class PPI
{
    public:

        PPI();
        void Welcome();
        void GetData();
        void Calculateppi();
        void Output();
        ~PPI();
    protected:
    private:
        int Width;
        int Height;
        int DR;
        float  ppi;
        float root;
        float Size;
};

#endif // PPI_H

Code:
// This is where all class Function is Defined..(Name = PPI.cpp)

#include "PPI.h"
#include <iostream>
#include <math.h>
#include<iomanip>

using namespace std;

PPI::PPI()
{
    //ctor
}

void PPI::Welcome(){

    cout<<setw(40)<<"Welcome"<<endl<<endl;
    cout<<"This Programme Will help you to calculate Pixel Per Inch (PPI) Of your screen"<<endl ;
    cout<<"\n\nThings you should have : "<<endl<<endl<<"1. Resloution"<<endl<<"2. Size of Screen in Inches"<<endl;

}

void PPI::GetData()
{

cout<<"\n\nEnter Resolution in this Format (1280 720) ::  ";
cin>> Width>> Height;

cout<<endl<<"\nEnter sice Of screen ::   ";
cin>>Size;
}


void PPI::Calculateppi(){

DR = (Width * Width) + (Height * Height);

root= sqrt(DR);

ppi = root/Size;


}


void PPI:: Output(){

cout<< "\n\nPPI of your Screen is :: " <<ppi<<endl;
}


PPI::~PPI()
{
    cout<<"\n\n Thank You for using this Programme."<<endl;
    cout <<"\n\nFor any feedback Pls Contact :: feedback@No-one.com";
}

Edit: oops I find out My own mistake.. I made constructor and that Welcome Data was supposed to be in Constructor function.. but while Writing I code I made another Function for it (welcome Function)
__________________
Athlon II X4 635 @ 2.9Ghz   Gigabyte GA-MA785GMT-US2H   Kingston 2x2 Gb 1333Mhz DDR3   WDC 500Gb Green   Palit GTS 250 512mb   Tagan 500W   Samsung B2030   Lg DVD Writer

Last edited by clmlbx; 18-10-2011 at 11:04 AM.
clmlbx is online now  
Old 19-10-2011, 11:12 PM   #744 (permalink)
THE UNLEASHED BEAST
 
somulesnar's Avatar
 
Join Date: Jan 2011
Location: Alexandria, Minnesota
Posts: 87
Default Re: Post your C/C++ Programs Here

hey guys here's a c program to merge two single linked lists.... i ve used switch case to get on over wid this prob can u suggest me an easier way....

Spoiler:
#include<stdio.h>
#include<conio.h>
#define null 0
void create();
void display();
void insert();
void delet();
void erase();
void create2();
void display2();
void insert2();
void delet2();
void erase2();
void link1();
void link2();
void merge();
struct node
{
int info;
struct node *next;
}*start,*ptr,*temp,*prev;
struct node2
{
int info;
struct node2 *nex;
}*start2,*ptr2,*temp2,*prev2;
void main()
{
int op;
clrscr();
do
{
printf("\n1.link1\n2.link2\n3.merge\n4.exit");
printf("\nEnter your option");
scanf("%d",&op);
switch(op)
{
case 1:
link1();
break;
case 2:
link2();
break;
case 3:
merge();
break;
case 4:
break;
default:
printf("\nEnter correct option");
}
}while(op!=4);
getch();
}
void create()
{
int data;
printf("\nEnter the data");
scanf("%d",&data);
do
{
ptr=malloc(sizeof(struct node));
ptr->info=data;
ptr->next=NULL;
if(start==NULL)
start=ptr;
else
{
temp=start;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=ptr;
}
printf("\nEnter the data & Press 0 to terminate");
scanf("%d",&data);
}while(data!=0);
}
void display()
{
temp=start;
if(start==NULL)
printf("\nList is empty");
else
{
printf("\nElements of list:\n");
while(temp->next!=NULL)
{
printf("%d\t",temp->info);
temp=temp->next;
}
printf("%d\t",temp->info);
}
}
void insert()
{
int data,pos;
printf("\nEnter data & position to insert the element");
scanf("d",&data,&pos);
temp=start;
ptr=malloc(sizeof(struct node));
ptr->info=data;
while(temp->next!=NULL)
{
if(temp->info==pos)
{
ptr->next=temp->next;
temp->next=ptr;
break;
}
else
temp=temp->next;
}
if(temp->next==NULL)
{
temp->next=ptr;
ptr->next=NULL;
}
}
void delet()
{
int pos,flag=0;
if(start==NULL)
printf("List is empty");
else
{
printf("Enter element to be deleted");
scanf("%d",&pos);
temp=start;
if(start->info==pos)
{
flag=1;
start=start->next;
free(temp);
}
else
{
while(temp->next!=NULL)
{
prev=temp;
temp=temp->next;
if(temp->info==pos)
{
flag=1;
prev->next=temp->next;
free(temp);
break;
}
}
}
if(flag==0)
printf("\nElement is not present in list");
}
}
void erase()
{
if(start==NULL)
printf("\nList is empty");
else
{
while(start->next!=NULL)
{
temp=start;
start=start->next;
free(temp);
}
temp=start;
start=start->next;
free(temp);
printf("list is erased");
}
}
void create2()
{
int data;
printf("\nEnter the data");
scanf("%d",&data);
do
{
ptr2=malloc(sizeof(struct node2));
ptr2->info=data;
ptr2->nex=NULL;
if(start2==NULL)
start2=ptr2;
else
{
temp2=start2;
while(temp2->nex!=NULL)
{
temp2=temp2->nex;
}
temp2->nex=ptr2;
}
printf("\nEnter the data & Press 0 to terminate");
scanf("%d",&data);
}while(data!=0);
}
void display2()
{
temp2=start2;
if(start2==NULL)
printf("\nList is empty");
else
{
printf("\nElements of list:\n");
while(temp2->nex!=NULL)
{
printf("%d\t",temp2->info);
temp2=temp2->nex;
}
printf("%d\t",temp2->info);
}
}
void insert2()
{
int data,pos;
printf("\nEnter data & position to insert the element");
scanf("d",&data,&pos);
temp2=start2;
ptr2=malloc(sizeof(struct node2));
ptr2->info=data;
while(temp2->nex!=NULL)
{
if(temp2->info==pos)
{
ptr2->nex=temp2->nex;
temp2->nex=ptr2;
break;
}
else
temp2=temp2->nex;
}
if(temp2->nex==NULL)
{
temp2->nex=ptr2;
ptr2->nex=NULL;
}
}
void delet2()
{
int pos,flag=0;
if(start2==NULL)
printf("List is empty");
else
{
printf("Enter element to be deleted");
scanf("%d",&pos);
temp2=start2;
if(start2->info==pos)
{
flag=1;
start2=start2->nex;
free(temp2);
}
else
{
while(temp2->nex!=NULL)
{
prev2=temp2;
temp2=temp2->nex;
if(temp2->info==pos)
{
flag=1;
prev2->nex=temp2->nex;
free(temp2);
break;
}
}
}
if(flag==0)
printf("\nElement is not present in list");
}
}
void erase2()
{
if(start2==NULL)
printf("\nList is empty");
else
{
while(start2->nex!=NULL)
{
temp2=start2;
start2=start2->nex;
free(temp2);
}
temp2=start2;
start2=start2->nex;
free(temp2);
printf("list is erased");
}
}
void link1()
{
int op;
start=NULL;
do
{
printf("\n1.create\n2.display\n3.insert\n4.delete\ n5.erase\n6.exit");
printf("\nEnter your option");
scanf("%d",&op);
switch(op)
{
case 1:
create();
break;
case 2:
display();
break;
case 3:
insert();
break;
case 4:
delet();
break;
case 5:
erase();
break;
case 6:
break;
default:
printf("\nEnter correct option");
}
}while(op!=6);
getch();
}
void link2()
{
int op;
start2=NULL;
do
{
printf("\n1.create\n2.display\n3.insert\n4.delete\ n5.erase\n6.exit");
printf("\nEnter your option");
scanf("%d",&op);
switch(op)
{
case 1:
create2();
break;
case 2:
display2();
break;
case 3:
insert2();
break;
case 4:
delet2();
break;
case 5:
erase2();
break;
case 6:
break;
default:
printf("\nEnter correct option");
}
}while(op!=6);
getch();
}
void merge()
{
if(start==NULL)
{
start=start2;
}
else
{
temp=start;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=start2;
}
temp=start;
if(start==NULL)
printf("\nList is empty");
else
{
printf("\nElements of list:\n");
while(temp!=NULL)
{
printf("%d\t",temp->info);
temp=temp->next;
}
}
getch();
}
__________________
Core i7 930 ,msi x58-pro, 2x2gb ddr3 corsair xms, msi gtx 570,corsair hx 620, Wd 1tb blue , cm 690 , samsung 2233 ,apc 800va , altec lansing vs2621, hp probook core i5 450+4gb ram+320gbhdd
somulesnar is offline  
Old 27-11-2011, 09:57 AM   #745 (permalink)
Right Off the Assembly Line
 
Join Date: Nov 2011
Posts: 1
Default Armstrong value program

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int save,number,digit,count=0,rev=0,m,n,save2;
clrscr();
printf("Enter number to print=");
scanf("%d",&number);
save=number;
save2=number;
while(number!=0)
{
m=number%10;
digit=m/m;
count=count+digit;
number=number/10;
}
printf("\n %d",count);
while(save!=0)
{
n=save%10;
rev=rev+pow(n,count);
save=save/10;
}
printf("\n %d",rev);
if(rev==save2)
{
printf("\nEnter number is Armstrong");
}
else
{
printf("\nEnter number is not armstrong");
}
getch();
}
raj100 is offline  
Old 27-11-2011, 11:31 AM   #746 (permalink)
BIOS Terminator
 
nims11's Avatar
 
Join Date: Apr 2008
Location: Ranchi
Posts: 816
Default Re: Armstrong value program

Spoiler:

Quote:
Originally Posted by raj100 View Post
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int save,number,digit,count=0,rev=0,m,n,save2;
clrscr();
printf("Enter number to print=");
scanf("%d",&number);
save=number;
save2=number;
while(number!=0)
{
m=number%10;
digit=m/m;
count=count+digit;
number=number/10;
}
printf("\n %d",count);
while(save!=0)
{
n=save%10;
rev=rev+pow(n,count);
save=save/10;
}
printf("\n %d",rev);
if(rev==save2)
{
printf("\nEnter number is Armstrong");
}
else
{
printf("\nEnter number is not armstrong");
}
getch();
}


live in present buddy!
__________________
Arch Linux is kind of a bonzai tree, over years u try new things, make small tweaks, and end up with a system that is unique, elegant, and does exactly what u designed it to do.
Hostapd : The Linux Way to create Virtual Wifi Access Point
My Blog
nims11 is online now  
Old 27-11-2011, 05:20 PM   #747 (permalink)
Right Off the Assembly Line
 
Join Date: Mar 2009
Location: hydrabad
Posts: 8
Default Re: Post ur C/C++ Programs Here

Quote:
Originally Posted by Ron View Post
scanf("%d%d%d",&a,&b,&c);
New to c++.......Whta those this line means
scanf() takes input from standard input(key board) and stores in some variables.

%d is called format specifier for integer variable, it tells compiler that coming input from the keyboard is an integer .

next is &a , this is the address of the variable "a" which needs to be passed to the scanf()
to store the input data in variable "a".

so by combing all compiler now knows that input data needs to be stored in an integer variable and the variable is a.

now in your question there are three inputs coming from your key board so you have 3 %d and the three address of the variables that is &a,&b,&c.
priyaranjan is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


LinkBacks (?)
LinkBack to this Thread: http://www.thinkdigit.com/forum/programming/67133-post-your-c-c-programs-here.html
Posted By For Type Date
Post ur C C Programs Here Programming Question Post #0 Refback 15-04-2011 07:41 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Uninstall programs, not listed in add/remove programs Aanand QnA (read only) 9 06-06-2008 07:00 PM
Deathly Hallows Released : Post Comments (Don't post Spoilers) Quiz_Master Chit-Chat 142 31-07-2007 10:49 PM
Make a folder in "start>programs" menu & move programs to it Aanand QnA (read only) 5 26-10-2005 12:25 AM

 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2