Try Geany. Make sure your paths are configured, and g++ and gcc works from the command line.
Quote:
Originally Posted by vickybat
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).
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.
Advertisements. Register and be a member of the community to get rid of them.
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......
^^ 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.
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.....
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
^^ 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.
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.
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.
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
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.
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_
^^ 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...
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
somulesnar
Answer this.
yes my prob is with the recursion concept of this prob only...
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
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
^^ 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
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 *l, int pos, int len); void pass(int *l, int len);
int main(void) { int i; int list[LEN];
for(i = 0; i < LEN; ++i) { printf("Enter for %d: ", i+1); scanf("%d", &list[i]); }
pass(list, LEN);
for(i = 0; i < LEN; ++i) { printf("%d ", list[i]); } puts(""); // Put a newline at the end of program's stdin
return 0; }
void send_max_to_rear(int *l, int pos, int 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(l, pos+1, len); // Move to the next position to compare. } }
void pass(int *l, int 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(l, 0, len); pass(l, len - 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.
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.
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)
#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