Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Emergency !! C Questions (http://www.go4expert.com/forums/emergency-c-questions-t8162/)

frankie123 8Jan2008 19:02

Emergency !! C Questions
 
!!! Emergency !!!

Following are some questions I need answers for

Please explain your answers

char my_char;
int my_ int, a,b,c;
char my_string[200];
char* my_c_ptr;


1.
my_char = "5423585969770"[my_int];

a .my_char must be replaced by my_c_ptr
b.the C syntax is not correct
c.my_char is assigned to point to a character array of size my_int containing text 5423585969770.
d. my_char should be replaced by my_string
e.other


2.

enum { one, two, three };

a.two has value of 3
b.structure called enum is defined containing 3 elements
c. three has a value of 1 greater than two
done , two , three need to be predefined


3.
a = b = c == 5;

a. is equivalet to ((a=b)=c) ==5
b. the syntax is not correct
c. aand b will be assigned a value of either 0 or 1
d. a, b , c are all assigned 5

Salem 8Jan2008 19:27

Re: Emergency !! C Questions
 
http://www.catb.org/~esr/faqs/smart-...ns.html#urgent

> Please explain your answers
Please explain your lack of an attempt at the solution, or your disregard of the forum posting guidelines.
http://www.go4expert.com/showthread.php?t=168
http://www.go4expert.com/faq.php?faq=guidelines
We're not here to give you answers on a plate so you can get a decent grade you don't deserve.

You have a guess (or better yet, think about it and refer to some notes) and explain your reasoning, then we tell you where the faults in your reasoning might be.

The real answer to Q1 isn't even on your list.

frankie123 8Jan2008 19:39

Re: Emergency !! C Questions
 
Dear Salem

regarding Q1. I created he same code which passed by the compiler with no errors raised .

Q2. regarding definition of enum . The syntax enum variable _name {.....,.....,.... }; I have tried finding if the variable name is optional however every where its there in the syntax.
i believe (3) to be corect for this question

Q3. ran program which does assign 0 to both a, b but c gets a number 356, which is not mentioned in the statement. I presume since == returns that s is not equal to 5 , that value is assigned to a and b .
ans (c)

I am not trying to break forum rules . I am new to C.


All times are GMT +5.5. The time now is 04:00.