Monday, July 27, 2009

Doubt in C Language?

I am giving my problem here:





main()


a=p1.0; \\ like this I am having 16 variables upto p1.15


b=p2.0;





int c[]={a,b,c,....}; \\I need the value of p1.0 to be passed to a,b,c... correspondingly...??





for (i=0;i%26lt;15;i++)


{


if (c[i]==1) // agian, I would like to call the value which is assigned from p1.0 to a at this line? (ie) need to check the value of a in this if statement.??


bla bla..


}

Doubt in C Language?
You have several problems with this program...





First of all, you aren't declaring your variables (a, b, ..). if you put a letter in there, like p, it's a string. If you want them to be a decimal number, it's a float.





So then when you make your array, your values are not integers like you declared (int c[]). They need to be the same as you declared the values before (strings or floats). And, you shouldn't reuse variables like that (if you have a value called c, don't have an array called c. Give them more descriptive names).





Then when you're comparing it to a number, make sure it will actually match what the value in the variable is. If you want to compare the number 1 to the 'a', then a must equal 1, not p1.0.





It looks like you have the right idea for what you want to do, just check your syntax.. a lot!
Reply:You should use pointers and for that you should know pointers. You can learn using pointers by Yashavant Kanethkar's book "Pointers in C".
Reply:leave it , this not a correct programme


No comments:

Post a Comment