473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

switch problem - interesting !!

#include<stdio.h>
int main(void){
int q,i,j,count;
i=j=0;
q=2;
count=6;
switch(3){
case 0:
while(--count>0){
case 1:
printf("case-1\n");
++j;
case 2:
printf("case-2\n");
++i;
case 3:
printf("case-3\n");
case 4:
printf("case-4\n");
case 5:
printf("case-5\n");
}
}
printf("%d %d\n",i,j);
return 0;
}
case-3
case-4
case-5
case-1
case-2
case-3
case-4
case-5
case-1
case-2
case-3
case-4
case-5
case-1
case-2
case-3
case-4
case-5
case-1
case-2
case-3
case-4
case-5
case-1
case-2
case-3
case-4
case-5
5 5
gives me this !!
I thought compiler will give some sort of parse error. Please explain.

Thanks

Dec 15 '06 #1
1 1043
onkar said:

<snip>
I thought compiler will give some sort of parse error. Please explain.
See FAQ 20.35.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Dec 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Rudi Hansen | last post by:
I dont seem to be able to find the switch statement in Python. I would like to be able to do switch(var) case 1 : print "var = 1" case 2: print "var = 2"
10
by: Myster Ious | last post by:
Polymorphism replaces switch statements, making the code more compact/readable/maintainable/OO whatever, fine! What I understand, that needs to be done at the programming level, is this: a...
16
by: Teffy | last post by:
Should I switch from using HTML-Kit to using Adobe GoLive? I am just a volunteer who is webmaster for a small non-profit group. I am the only person working on the site. The only reason I am...
8
by: Dave | last post by:
Hello all, Consider the case of an if with many else if clauses vs. a switch with many cases. In thinking about how such control constructs would likely be implemented, it would seem that...
37
by: Thomas Matthews | last post by:
Hi, My son is writing a program to move a character. He is using the numbers on the keypad to indicate the direction of movement: 7 8 9 4 5 6 1 2 3 Each number has a direction except...
27
by: Yuriy Solodkyy | last post by:
Hi VS 2005 beta 2 successfully compiles the following: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
25
by: v4vijayakumar | last post by:
'continue' within switch actually associated with the outer 'while' loop. Is this behavior protable? int ch = '\n'; while (true) { switch(ch) { case '\n': cout << "test"; continue; } }
12
by: | last post by:
Is it fine to call another method from Switch? Eg. Switch (stringVar) { case ("a"): somVar = "whatever"; Another_Method(); //call another method return;
22
by: John | last post by:
Hi Folks, I'm experimenting a little with creating a custom CEdit control so that I can decide on what the user is allowed to type into the control. I started off only allowing floating point...
5
by: CSharper | last post by:
I have a hashtable which has key and value. If the key is set to 'a' then I need to create a class1 and if it has key 'b' then I need to create class2 etc. (There is no name relation between the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.