Whats wrong in this code fragment?

hello,
what is the error in this code fragment?

1
2
3
4
  if(x==1)
    k=100;
  else
    k=10;


thanks
did you change the question? :s
Last edited on
did you add the preprocesser directive (#include <iostream>) and termination code (return 0;)?

i came up with something using what you posted:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

using namespace std;

int main ()
{
	int x,
	    k;

	cout << "Enter x: ";
	cin >> x;

	if(x == 1)
	    k = 100;
	  else
	    k = 10;

	cout << "k is " << k;

	return 0;
}
no no it is just a theory question and sorry the format written was wrong
I actually(by mistake) wrote the correct answer :p
Thanks btw.

the original question had (x=1). :-)
Topic archived. No new replies allowed.