Home Tutorialhelp Comment Can we declare a variable in switch in C lang

 
 

Comment

ashish
Can we declare a variable in switch in C lang,
October 9, 2010 at 1:09 PM

Hi,
Can we declare a variable in switch statement before any case starts.
like as shown below,
switch(a)
{
int b=20;
case 1: printf("b is %d\n",b); break;
}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
C++

C Tutorials
of a String in C. You can see in the given example, we have declared a string... illustrates you to delete a file in C. You can see in the given example that we want... from Celsius to Fahrenheit in C. You can see in the given example, we prompt 

Java Beginners

Can we declare a static variable inside a method?
Can we declare a static variable inside a method?   Hi, Can we declare a static variable inside a method? thanks 

Java Tips and Examples

Switch
statements. To avoid this we can use Switch statements in Java. The switch statement... of a variable or expression. The switch statement in Java is the best way to test... to the end of the switch statement. Remember, if we won't use break statement 

Programming Tutorials

C++Tutorials
to teach C++ in a way that makes use of what the language can offer. C++ shares...    C++: A Historical Perspective We begin our journey of C... of C++. It is aimed at experienced C users who wish to learn C++. It can also 

Tools For Java Technology

The Switch statement
. To avoid this we can use Switch statements in Java. The switch statement is used... of a variable or expression. The switch statement in Java is the best way to test... the computer jump to the end of the switch statement. Remember, if we won't use break 

Java Interview Questions

C interview questions
C interview questions  Plz answer the following questions... since each node "nPtr" is freed before its next address can be accessed. c... and a definition of a variable? a. Both can occur multiple times, but a declaration 

Java Interview Questions

C interview questions
C interview questions  Plz answer the following questions... since each node "nPtr" is freed before its next address can be accessed. c... and a definition of a variable? a. Both can occur multiple times, but a declaration 

Java Beginners

variable declaration in c and c++
variable declaration in c and c++  Comparison and an example of variable declaration in C and C 

Free C++ books

C/C++ Programming Books
language like C++. In this ebook we give you a good start for a programming standard... Press, we are able to bring you the complete Numerical Recipes in C book On-Line... C/C++ Programming Books       

IDE Questions

c programme
c programme  When we drop a ball on a rigid surface it bounces from the surface upto a height which can be expressed as some percentage of its... a program in C that where the user will input an initial height(in metres) and also 

General

Ask C/C++ Questions online
Ask C/C++ Questions online       C and C++ are different programming... purpose programming language that can run on most of the platforms. C is used 

CVS Questions

C++
C++  How can i write this in dev c 

Development process Questions

C++
C++  How can i write this in dev c 

Programming Tutorials

Pointer in C
. In the above figure you see that c is a variable of char data-type and it has value "A" inside. The address of variable c is 0X3000 Now in this figure you see that c is a variable of char data-type and it has value 'A' 

Java Beginners

c++
c++   Assume vector "x" of integers with values of 7, 3, 5, 8, 1, 9...) increments its control variable; 3.2) has a control variable named "i," with an initial of the value of variable "a"; 3.3) has a final value of its control 

UML Questions

c++
c++  Write the definition of the class dayType that implements... on an object of type dayType: a. Set the day. b. Print the day. c. Return the day... is Monday and we add 4 days, the day to be returned is Friday. Similarly 

iPhone

Objective-C keywords
Objective-C keywords       Here in this section we will know about the keywords used in objective-C language. Objective-C is a superset of C language, so program written in c 

PHP Tutorial

PHP Variable Outside Function
PHP Variable Outside Function In PHP Functions, a variable can be called either outside the function or inside the function. If we declare a variable within...; The output of the above example is : Notice: Undefined variable: text in C 

Java Beginners

C# question
C# question  How can we call method pass by reference in C 

Mobile Applications Questions

global variable in objective c
global variable in objective c  Declaring global variable in objective c 

Java-Tutorials

Lang and Util Base Libraries
package or in other words we can say that this feature provides us the package...Lang and Util Base Libraries The Base libraries provides us the fundamental features and functionality of the Java platform. Lang and Util Packages Lang 

Java Beginners

basic c/c++ questions
basic c/c++ questions  Are the Control statements like if(),while() in built functions? if no, why not as they satisfy all the properties of a function 

Java Beginners

basic c/c++ questions
basic c/c++ questions  Are the Control statements like if(),while() in built functions? if no, why not as they satisfy all the properties of a function 

Java Beginners

Declare Reference variable
is shared. I just want to ask if we declare Reference variable above then what does...?? (Generally we used to declare reference variable in main method at the time...Declare Reference variable   class A { int a; //instance 

Java Beginners

C/C++ QUESTIONS
C/C++ QUESTIONS  ??Write a function for finding out the occurences of repeated word from a sentence. This function would return an array of duplicate words. 

C Tutorials

C Structure example
, you can declare a structure variable by preceding the variable name... C Structure example       This section illustrates you the concept of structure in C. Structures 

Mobile Applications Questions

objective c pass by value
{ //j == 0, and this points to i! We can modify i from here. *j = 23; //j...objective c pass by value   How to pass value by reference in objective c?   - (void)parentFunction { int i = 0; [self 

iPhone

Declaring Method in Objective C
Declaring Method in Objective C In Objective C we can declare two types...: + (void) printData; - (void) printData; The forgoing Objective C methods... (void) and the method name (printData). You can also declared a method 

IDE Questions

c++ - IDE Questions
c++  how can i write a simple program in c++ that outputs 399 in words?thank you.  Hi Friend, C program to convert number to words: #include #include char *ch1[]={" "," one"," two"," three"," four"," five 

Java Interview Questions

Difference between C++ and Java - Java Interview Questions
++ is but not in Java.4. In C++ you have to re-declare static data members outside...++, but in C++ programming can be done without making objects.Java is a high level...Difference between C++ and Java  Basic difference between C 

Java Beginners

C/C++ QUESTIONS
C/C++ QUESTIONS  "Write a function for finding out highest and lowest marks obtained by a student from an array contained student name and marks". For Example : GetHighestLowestMarks{Student{n}, Marks{n}} returns 

Java Beginners

java & c
, compilation of the definition of these data types are performed. Thus we can say...java & c  why c language is called top down approach? why java is called bottom to top approach?   In C, compilation stats from the very 

Java Interview Questions

C - Java Interview Questions
C  Void main() { int i=7; print f("%d",i++*++i); } Output:  Hi Friend, Output is 63. As you have set the value 7 to the variable i.The i++ increments the number after its use therefore it uses 7 

Design concepts & design patterns Questions

classes in c++
classes in c++  1- design and implement a class datatype... and we add 4 days .the day to be returnd is friday.similarly, if today is tuesday and we add 13 days, the day to be returned is monday/ add the oppropriate 

iPhone

Objective C on Windows
on Windows machine. We will download and install Objective C Windows compiler. On windows GNU C compiler can be used to compile the Objective C program. Objective C Compiler for Windows The GNUstep windows installer can be downloaded 

Programming Tutorials

C++GraphicsTutorials
C++ Graphics Tutorials     ... in this document is correct. C/C++ Windows programmers who want to learn... MFC.      OpenIL in Dev-C++ OpenIL 

IoC Questions

Array in C
Array in C  Respected Sir, How can an array be an lvalue, if we can't assign to it? How can I set an array's size at run time? How can I avoid fixed-sized arrays? help me sir 

C Tutorials

C Break with Switch statement
C Break with Switch statement   ... with Switch-Case in C. The switch case statements allows to control complex... shows the error message. You can see in the given example, the program prompts 

iPhone

Objective C Tutorial
; In this Objective C Tutorial we will provide you step-by-step information in detail. You will find this object c tutorial very useful. You can quickly... experience in C language. If you have good knowledge of C then you can learn 

iPhone

Objective C
Objective C tutorials. We will be explaining the programming language with easy... Objective C? In this section we will learn about the importance of Objective C... In this section you will learn how to use Objective C on Windows machine. We 

C Tutorials

C String length
in C. You can see in the given example, we have declared a string and initialize a variable i to 0. The while loop will increment the value of i till it reach... C String length       

C Tutorials

C Structure Pointer
can see in the given example, we want to access the employee's information through structure pointer. For that, we declare the structure type st consisting... C Structure Pointer       

Mobile Applications Questions

objective c boolean example
objective c boolean example  Hi, Can anyone tell me how to use boolean variable in Objective c? Thanks 

iPhone

Objective C Array
Objective C Array In a simple term we can say that array is a object, which is a collection of number of other objects. In Objective C, we can also add.... Syntax to declare an Array in Objective C: NSArray *myArray 

Blog

Site map - C Tutorials
for loop | C Break with Switch statement  | C String length | C array...Index  | About-us | Contact Us | Advertisement | Ask Questions...; C Tutorials  | Java Tutorials | PHP Tutorials  | Linux 

Mobile Applications Questions

@Protocols in Objective C
@Protocols in Objective C  Understanding @Protocols in Objective-C   @protocol in objective c @protocol is the keyword type in Objective C. Which is used to declare a formal protocol. You can find more Objective c 

Java Beginners

questions
. Programmatic if we want make any method as instance method that method can... programes on switch 1. write a program to design menu driven arithmetic... b. write a program to to calculate factorial of a no. c. write a program 

Java Beginners

c++ - Java Beginners
c++  can i connect c++ with database like in java. do we need any special software for this purpose 

iPhone

Objective C Constructors
Objective C Constructors       Objective-C enables user to define constructor with the help of self and super keywords. Like java Objective-C has parent class and programmer 

JSP Interview Questions

Declare Methods is _jspService() only - JSP-Interview Questions
Declare Methods is _jspService() only   Hi Friends, My interviewer said, any methods if u want to use ,should declare in d _jspService method.But i said we can declare inside scriplets.which is correct plz tell me 

C Tutorials

C array of pointers
variable. Then specify the name of variable. You can see in the given example... C array of pointers      .... A pointer is a variable that contains the memory location of another variable 

Java Beginners

how java programming differ from pascal and C - Java Beginners
"void" is not really a valid variable type, it can only be used when declaring... have to read about it for my exams thanks  Hi friend, C... functions, and routines that don't return a value are called procedures. In C all 

Java Tips and Examples

Example of a instance variable
be referenced from a static context. We can call the non-static variable by the instance... of this variable is given below : As we can see in the output the same copy of the instance..., not the updated one . In this program we are showing that how a instance variable 

Mobile Applications Questions

Why NSString Objective C
Why NSString Objective C  Why we use the NSString class in Objective C and how to define and initialize the NSString Class?   Why NSString Objective C NSStrings is a class that deals with strings in objective c 

Mobile Applications Questions

cannot declare variable inside @interface or @protocol
cannot declare variable inside @interface or @protocol  When i declare variable inside the interface, it always send an error saying "cannot declare variable inside @interface or @protocol". Can anyone please tell me why 

Ajax Questions

c#
c#  how to find out the size of the BMP image in C 

PHP Tutorial

PHP Variable
of the most important thing, in PHP we can declare a variable of any type, any where... of $var is: 1 Value of $var is: c From the above example we can easily.... Sometimes we need to print Double quote, Single quote, Variable names as a statement 

Java Beginners

c++ - Java Beginners
c++  1. Create the equivalent of a four-function calculator... a switch statement to select the operation. Finally, display the result. When... calculation. The response can be 'y' or 'n'. Some sample interaction 

General

C Tutorials
instances are comparable, we can sort them in any order. Comparable... the command line. Classpath can also be though an environment variable. Classpath specify... C       Java 

JSTL

Create URL using <c:url> tag of JSTL Core tag library
 Declare a scoped variable that stores the url.... context  We can provide context.... We have also used tag <c:param> to add 

Java Tips and Examples

Switch case in java
Switch case in java In this section we will learn about switch case in java... the input from the user and passing that variable to switch case depending.... A statement in switch is labeled with one or more case or default. If we talk about 

Development process Questions

c++
c++  use a prgrm as an example to xplain-: a)class b)object c)message d)cope resolution operator 

Ajax Questions

c#
c#  how to find out the size of the BMP image 

Development process Questions

c++
c++  write a programme that calculates the area and circumference of a rectangle 

Development process Questions

C++
C++  dear sir How to create windows form application for login screen using C++? USER Name -TESTADMIN Password -testuser 

Java Beginners

c++
c++  i use turbo c++...i want to change the background color...what is the command for it and the header file used 

Java Beginners

c++
c++  i use turbo c++...i want to change the background color...what is the command for it and the header file used 

Java Beginners

c++
c++  i use turbo c++...i want to change the background color...what is the command for it and the header file used 

Regex Questions

Regular expression in c++{MFC}
of %5C & %2F character. How can we develop a generic Regular Expression...Regular expression in c++{MFC}  Hi ALL, I want to build a regular expression in c++{MFC} which validates the URL. The regular expression must 

Development process Questions

C++
C++  differenciate btw.-a)local & public variables b)pre-defined & user defined functions c)fnctn prototype,defination & fnctn code.use code examples 

Development process Questions

c++
c++  differenciate btw.-a)local & public variables b)pre-defined & user defined functions c)fnctn prototype,defination & fnctn code.use code examples 

Development process Questions

c++
c++  differenciate btw.-a)local & public variables b)pre-defined & user defined functions c)fnctn prototype,defination & fnctn code.use code examples 

Design concepts & design patterns Questions

C++
C++  Trace the bubble sort using the following integers,which represent the elements in an array. 5,7,3,8,6,7,3 

Development process Questions

c++
c++  write a prgrm tht accepts 3 integer values,then with a function to swap the values 

Java Beginners

C++
C++  Describe the principle advantages of deploying a linked list versus a static array when implementing a Queue or a Stack 

Design concepts & design patterns Questions

c programming
c programming  how can i get the ouput in the format of a a b a b c 

Design concepts & design patterns Questions

c programming
c programming  how can i get the ouput in the format of a a b a b c 

Design concepts & design patterns Questions

c programming
c programming  how can i get the ouput in the format of a a b a b c 

JDBC Questions

c++ - JDBC
c++  Can any one given a note on advantages and disadvantages of C 

C Tutorials

C Array Declaration
; In this section, you will learn how to declare an array in C. To declare an array in C, you have to specify the name of the data type and the number.... Similarly, you can declare the array of float type and char type. At the time 

Java Beginners

C#
C#  i need a code that will make program perform the basic operations upon the data Listview save, update and cancel 

Development process Questions

C++
C++  I have been asked to write a programme that gets five values,gets the sum,average and product please help me 

Development process Questions

C#
C# register form  i want to generate a user id automatically after filling their register form and i want to show their id to their email? please reply me soon 

UML Questions

c++
c++  Consider the following function: int funcExercise7(int list[], int size) { int sum = 0; for (int index = 0; index < size; index++) sum = sum + list[index]; return sum 

UML Questions

c++
c++  Consider the following declarations: class xClass { public: void... private members does class xClass have? c. How many constructors does class xClass.... Write a C++ statement that prints the values of the data members of the object 

Development process Questions

c++
c++  .write a program that accepts 5 subjects of a student,it should have a function to calculate the average & another function to grade.grade should be as follows-<40=E,40-49=D,50-59=C,60-69=B & >70 

Development process Questions

c++
c++  write a prgrm tht calculates the surface area of a cylinder.the prgrm shld find the circumfrance and have a function that calculates the fadius and another to calculate the surface area 

Development process Questions

C++
C++  write a prgrm tht gets five values,gets the sum,average &...; #include <conio.h> void main() { clrscr(); int a,b,c,d,e,sum; float average...;>b>>c>>d>>e; sum=a+b+c+d+e; average=sum/5; product=a*b*c*d 

Spring Framework Questions

c++
c++  write a program that gets a key or character from the keyboard and displays it ASII code in decimal, hexadecimal and binary form.It must also give a description of the key pressed 

Tutorials

What is Objective c iPhone?
language or we can also say that it is an enhanced version of traditional c... programming language?But in short, we can say that it?s a basic oops concept.... The latest version of Objective c programming is Objective c 2.0. You can download full 

UML Questions

c++
c++  Consider the following declarations: class xClass { public: void func(); void print() const; xClass (); xClass (int, double); private: int u... private members does class xClass have? c. How many constructors does class xClass 

C++

Java vs C
Java vs. C Language In this section we will compare Java and C Programming.... It can run on almost all the Operating Systems including windows, linux, solaris etc. It is not necessary to compile the program for each platform. The C 

CVS Questions

c++
c++  Write a console based C++ program that reads student information from a text file, build an array of objects of type class StudentInfo... name with the minimum GPA 7) Display Student GPAs as Letter Grades (A, B, C, D 

UML Questions

c++
c++  Characterize the following algorithm in terms of Big-O notation. for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 1; k <= n; k++) cout << i + j + k 

UML Questions

C++
C++  . Consider the definition of the following class: class CC { public: CC(); //Line 1 CC(int); //Line 2 CC(int, int); //Line 3 CC(double, int); //Line 4 . . . private: int u; double v 

UML Questions

c++
c++  Characterize the following algorithm in terms of Big-O notation. Also find the exact number of additions executed by the loop. (Assume that all variables are properly declared.) for (int i = 1; i <= n; i++) sum = sum + i 

Development process Questions

c++
c++  .write a prgrm tht accepts 5 subjects of a student,it shld hv a function to calculate the average & another function to grade.grade shld be as follows-<40=E,40-49=D,50-59=C,60-69=B & >70 

Java Beginners

C Structure
C Structure  Respected sir, Can a structure in C contain a pointer to itself ? if yes means how sir ? plz help me sir 

Java Beginners

C/C++/JAVA Question on function
other data type also.â?? Question can be solved in C,C++ or JAVA. (Recommneded - C...C/C++/JAVA Question on function  "Write a function to find out common 

C Tutorials

C Multiple Indirection
in the given example, we have declared an integer variable i initialized to 100... C Multiple Indirection   ... Indirection. C permits the pointer to point to another pointer. This creates many 

Advertisements Advertisements
 

 

 

DMCA.com