Post your C/C++ Programs Here

Status
Not open for further replies.

QwertyManiac

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

aditya.shevade said:
Try if you can, else I will send you the entire project by mail. The compressed (tar.bz2) file is about 1000KB.
That's okay, never mind, seems beyond my mind right now. Someone else like Yamaraj or Sykora might be able to answer it I s'pose. Am not that good really, yet :p

And a doubt:
Does Anjuta automatically create Header files or did you _HAVE_ to code them?
 
Last edited:

QwertyManiac

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

Alright, am trying my best right now. (I sure am tired after this).

Hopefully would tell you a few ways to implement inheritance into it after going through entirely.

/Me does a sudo apt-get install anjuta

Edit: You need to document your files .. Comments make it easier :(
 
Last edited:

vinit suri

Broken In
Re: Post ur C/C++ Programs Here

hey guys i needed ur help wid a c program.....

cud sm1 plzz post dis program 4 me...plzzzzz
d program is that....

it should accept any number between one and thousand and find the first non zero digit of the factorial of dat number from the right hand side.....


plz plz plz help me...
 

mehulved

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

Shouldn't that be easy.
1) Find the factorial
2) Divide it by 10
3) Check the remainder
4) If it's 0 discard it
 

vinit suri

Broken In
Re: Post ur C/C++ Programs Here

d question is which datatype 2 use....
v are talkin abt d factorial of even 1000....
so ders no datatype which can store dat....finding factorial is impossible....

hey guys i needed ur help wid a c program.....

cud sm1 plzz post dis program 4 me...plzzzzz
d program is that....

it should accept any number between one and thousand and find the first non zero digit of the factorial of dat number from the right hand side.....


plz plz plz help me...
__________________
 
Last edited:

The_Devil_Himself

die blizzard die! D3?
Re: Post ur C/C++ Programs Here

You can use exponential form i.e. aeb= a into e raised to the power b.Its limits is from -3.4e38 to 3.4e38.Hope this helps.I have never used it so don't ask how to implement it.

BTW your question looks like picked up from CAT or something.I'm sure of some trick involved.
 

aditya.shevade

Console Junkie
Re: Post ur C/C++ Programs Here

^^ trick might be that, if you multiply by 1000 then the first non zero from right cannot be 1 to 3 as there will be three zeros already. Also, for 1000, you will have 990 so add one more zero, 980 another zero and so on.

It's not easy this way, but worth a try.
 

aditya.shevade

Console Junkie
Re: Post ur C/C++ Programs Here

QwertyManiac said:
Edit: You need to document your files .. Comments make it easier :(

Actually, even I thought I should but after a couple of my friends who are not very good at C/C++ also understood the code just be the names of the variables, I think I can save the trouble.

So, I just added a naming conventions file as a documentation, and forgot to add it in the zip archive.

Here it is by the way, if you would like.

Aditya
 

Batistabomb

Deadman Walking
Re: Post ur C/C++ Programs Here

do namespacestd,exception handling concepts are working for you in turbo c++ on windows platform ?

Gigacore said:
Hi guys n gals,

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......

Use this Pattern:

A Program to find the largest of three numbers using nexted if

Code:
#include <stdio.h>
main()
{    
    int    a,b,c,big;
    printf("Enter Three numbers");
    scanf("%d%d%d",&a,&b,&c);
    if(a>b)
        if(a>c)
            big=a;
        else
            big=c;
    else
        if(b>c)
            big=b;
        else
            big=c;
    printf("Largest of %d,%d and %d = %d",a,b,c,big);
return 0;
}


great thought dude your's going to be the highest replies thread and most helpful in terms of exchanging knowledge
 
Last edited:

quan chi

mortal kombat
Re: Post ur C/C++ Programs Here

guys i have a problem.refer the program below.

i am starting from main.
Code:
void main()
{char name[30]
int x,y;
cout<<"enter your name"
cin>>name;
cout<<"enter your date of birth month and day only";
cin>>x;
cin>>y;
cout<<"****************"<<name<<"************* "
cout<<" your date of birth is"<<x<<"   "<<y;
if(x==2&y==3)
{cout<<"some result"
}
else
{cout<<"some result"
}
}
now in this program if i enter the name as "abceg"

the program outputs properly.

but if i enter something like "abced ghtyat"
it only takes my name it asks for dob but dosent take any input.
and take the dob as any garbage value by itself.
and outputs the else statements result.

please help.
 

The_Devil_Himself

die blizzard die! D3?
Re: Post ur C/C++ Programs Here

^^dude I think you can't use cin to input strings.use gets to input full names(i.e. with space in between).
 

Batistabomb

Deadman Walking
Re: Post ur C/C++ Programs Here

The_Devil_Himself said:
^^dude I think you can't use cin to input strings.use gets to input full names(i.e. with space in between).
you are right cin inputs strings but wont take spaces in the above program if you are typing your name with spaces then suddenly cin looks for the next cin i.e; x,y here
you can verify this by typing in output like this

abcd ghyt 1 2

so cout here is being neglected,so keep gets

#include<iostream.h>
#include<stdio.h>
void main()
{
char name[30];
int x,y;
cout<<"enter your name";
gets(name);
fflush(stdin);
//cout<<endl;
cout<<"enter your date of birth month and day only"<<endl;
cin>>x;
cin>>y;
cout<<"****************"<<name<<"************* ";
cout<<" your date of birth is"<<x<<" "<<y;
}
/*if(x==2&y==3)

cout<<"some result"

else

cout<<"some result"

} */
 

Sykora

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

If you're programming in C, use gets(). If you're programming in C++, use cin.getline()
 

aditya.shevade

Console Junkie
Re: Post ur C/C++ Programs Here

Sykora said:
If you're programming in C, use gets(). If you're programming in C++, use cin.getline()

I had been wondering about that... thanks. Needs some digging....
 

aditya.shevade

Console Junkie
Re: Post ur C/C++ Programs Here

Sykora said:
If you're programming in C, use gets(). If you're programming in C++, use cin.getline()

Hey... I did some digging as I said. And if you are using the string input type, then go for getline. Simple getline, not cin.getline.

The syntax is,

string someString;

std::getline(cin, someString);

cin is the same. It's better than cin.getline();

And you should use cin.ignore(); before the getline to make sure that stdin is clear.

Aditya
 
Status
Not open for further replies.
Top Bottom