Write a c program using for loop in switch case?



Write a c program using for loop in switch case?..

Answer / mmm

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
int code;
clrscr();
printf("menu\n");
printf("\npress 1 for positive numbers");
printf("\npress 2 for negitive numbers");
printf("enter code(1or2)");
scanf("%d",&code);
switch(code)
{
case 1: printf("\nfirst 10 positive numbers:");
for(i=0;i<10;i++)
printf("%d\n",i);
break;
case 2: printf("\nfirst 10 negative numbers:");
for(i=0;i<10;i++)
printf("-%d\n",i);
break;
default:printf("invalid code");
}
// printf("do you want to continue:yes or no");

getch();
}

Is This Answer Correct ?    41 Yes 2 No

Post New Answer

More C Interview Questions

Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

0 Answers  


Which driver is a pure java driver

0 Answers   Vertex,


what is disadvantage of pointer in C

13 Answers   Tech Mahindra,


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

0 Answers  


What is the purpose of ftell?

0 Answers  


How many ways are there to swap two numbers without using temporary variable? Give the each logic.

9 Answers  


What is the purpose of scanf() and printf() functions?

0 Answers  


How can you determine the maximum value that a numeric variable can hold?

0 Answers  


What is data structure in c and its types?

0 Answers  


program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.

3 Answers  


What is anagram in c?

0 Answers  


enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }

4 Answers   ME,


Categories