C/C++ Beginner's Guide and Post Basic Questions here

nims11

BIOS Terminator
1. and that wont affect the output in any case... except for maybe very long integers and i have tried long datatype too :(
2. so???

When you use floats instead of long, you are compromising on precision. It is common to to have little precision error leading to wrong answer when using floats in codechef like environment...

Btw the problem in your code is something else. (Check newlines).
 

rohitshubham

Ambassador of Buzz
When you use floats instead of long, you are compromising on precision. It is common to to have little precision error leading to wrong answer when using floats in codechef like environment...

Btw the problem in your code is something else. (Check newlines).
ermmm....newlines???
 

sksksksk

.:: un.Understandable ::.
Code:
int main(){   int test;
    float x1,x2,x3,y1,y2,y3,r;
    float dis1,dis2,dis3;
    cout<<"enter test cases";
    cin>>test;
    [COLOR="#FF0000"][SIZE=2]while(test--)[/SIZE][/COLOR]
    {
        cin>>r>>x1>>y1>>x2>>y2>>x3>>y3;
        dis1= pow((x1-x2),2) + pow((y1-y2),2);
        dis2=pow((x2-x3),2)+ pow((y2-y3),2);
        dis3=pow((x1-x3),2)+pow((y1-y3),2);
        r=pow(r,2);
        if((dis1<=r && dis2<=r)||(dis1<=r && dis3<=r)||(dis3<=r && dis2<=r))
            cout<<"yes";
        else
            cout<<"no";
    }
    return 0;

iThis is an invalid condition. The loop won't stop, as your condition is not well defined. I dont have any idea about what your program is but you can modify the condition, according to your need! :)
 
Code:
int main(){   int test;
    float x1,x2,x3,y1,y2,y3,r;
    float dis1,dis2,dis3;
    cout<<"enter test cases";
    cin>>test;
    [COLOR=#FF0000][SIZE=2]while(test--)[/SIZE][/COLOR]
    {
        cin>>r>>x1>>y1>>x2>>y2>>x3>>y3;
        dis1= pow((x1-x2),2) + pow((y1-y2),2);
        dis2=pow((x2-x3),2)+ pow((y2-y3),2);
        dis3=pow((x1-x3),2)+pow((y1-y3),2);
        r=pow(r,2);
        if((dis1<=r && dis2<=r)||(dis1<=r && dis3<=r)||(dis3<=r && dis2<=r))
            cout<<"yes";
        else
            cout<<"no";
    }
    return 0;

iThis is an invalid condition. The loop won't stop, as your condition is not well defined. I dont have any idea about what your program is but you can modify the condition, according to your need! :)

That is a perfectly valid condition. For non zero values, it will be evaluated as true and for zero and false.
 

kunalht

In the zone
Hii
I am in 1st year in computer scinece.
But in 1st sem. there is no subject of computer in college.
C programming subject will start from 2nd sem.
I want to learn something at home now.
I am thinking to learn C language.
Should I start learning C or should i learn any other language or HtML??
I have learned C language in 12th but it was very basic & i have also watched thenewboston's C progtamming videos.
now should i learn C first or directly C++?
& also suggest me a good book for that?
How is Ansi C 6th edition by balagurusamy?
should i buy that book?
Also tell me what to learn for android & windows phone development?
 

vickybat

I am the night...I am...
^^ For android development, you need to learn Java, which will show up later in your curriculum.
XML is required too and you need not worry about that now.

Now, i recommend you to buy this asap and start learning C.
It will not only help you immensely in the upcoming semester, but also make you comfortable with programming.

NewBoston videos are very good and you can watch those videos too along with reading.

P.S - Don't even think of buying that balagurysamy book.
 

rohitshubham

Ambassador of Buzz
^^ For android development, you need to learn Java, which will show up later in your curriculum.
XML is required too and you need not worry about that now.

Now, i recommend you to buy this asap and start learning C.
It will not only help you immensely in the upcoming semester, but also make you comfortable with programming.

NewBoston videos are very good and you can watch those videos too along with reading.

P.S - Don't even think of buying that balagurysamy book.
Why?? i find balagurusamy's book quite easily written for beginner.
 

vickybat

I am the night...I am...
Why?? i find balagurusamy's book quite easily written for beginner.

It does not encourage to code imo. Same with all indian authored books including "Let Us C".
I strongly advice beginners to stay away from these as there are better materials and books out there.

"Head First C" is the best example.
 

Nue

...
It does not encourage to code imo. Same with all indian authored books including "Let Us C".
I strongly advice beginners to stay away from these as there are better materials and books out there.

"Head First C" is the best example.

I agree with you. I always advise people to stay away from Balagarusamy and other Indian authors. They teach obsolete practices (like void main in C/C++ and iostream.h etc) and don't really help one in developing a programming mindset. I personally learned C from K.N King's book and I still think it's the best book on C out there. Head first series never really clicked with me but I'm always in the minority. It's a good recommendation as they don't seem to have any programming experience.
 

flyingcow

Shibe
I want to learn C, but im currently learning Visual Basic from the tutorials provided in this months digit CD (Taken from here-*www.learnvisualstudio.net/) I have already done the first 6-7 tuts. explaining the IDE and the fundamentals.
Does learning C make VB easier?? or there is no relation? I have previously learnt JAVA...please give your suggestions should I continue with VB or learn C first?
 

kunalht

In the zone
IN our collage the reference book for C is ansi C by balaguruswami.
So if i buy head first C, Does it cover all the topics of balaguruswami's book?
& also tell me is head first C is good for beginners like me??
 
IN our collage the reference book for C is ansi C by balaguruswami.
So if i buy head first C, Does it cover all the topics of balaguruswami's book?
& also tell me is head first C is good for beginners like me??

> head first will cover your entire syllabus and more.

> head first IS for beginners.
 

vickybat

I am the night...I am...
IN our collage the reference book for C is ansi C by balaguruswami.
So if i buy head first C, Does it cover all the topics of balaguruswami's book?
& also tell me is head first C is good for beginners like me??

Not only your college but it was the reference book in our college too, when i was a student.
Its the default choice in all engg.colleges in India. Now we can't change that as we don't have the authority to do so.
What we can do is find better alternatives to gain effective knowledge.

Head First C covers everything and is highly recommended. You won't miss out on anything, not opting for the balagurusamy book.
You will be able to write all the programs in a snap, your teacher advises. Just trust us on this mate and get that book eyes closed.
Read and practice the problems sincerely though. :)
 

Nue

...
I want to learn C, but im currently learning Visual Basic from the tutorials provided in this months digit CD (Taken from here-*www.learnvisualstudio.net/) I have already done the first 6-7 tuts. explaining the IDE and the fundamentals.
Does learning C make VB easier?? or there is no relation? I have previously learnt JAVA...please give your suggestions should I continue with VB or learn C first?

That depends on which area of programming industry you wish to enter and for what purpose you're currently learning vB. If you want to learn C simply out of intellectual curiosity or to become a better programmer then you can do it at any time...even alongside vB but I wouldn't recommend that :p Learning C won't make vB any easier. In fact, you mayfind it a bit hard to get used to the vB syntax after programming in C (note that the programming concepts and the logic remains the same regardless of the language). So I guess it really depends.
 

Nue

...
IN our collage the reference book for C is ansi C by balaguruswami.
So if i buy head first C, Does it cover all the topics of balaguruswami's book?
& also tell me is head first C is good for beginners like me??
We had that book in our college too. Pretty much the same case for every Indian college. Ignore it.
Yes and probably a lot more than that.
Head first series is beginner friendly afaik.
 
Top Bottom