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

what will be the output of "printf("%d%d",scanf("%d% d",&a,&b))".provide an explation regarding the question

6 Answers  


Explain zero based addressing.

0 Answers  


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

0 Answers  


What is c programming structure?

0 Answers  


Why structure is used in c?

0 Answers  






What is %g in c?

0 Answers  


What are the disadvantages of a shell structure?

0 Answers  


#include<stdio.h> main() { int i=5; printf("%d",i*i-- - --i*i*i++ + ++i); } tell the answer with correct reason .specially reason is important nt answer ans by turbo c is -39

1 Answers   GameLoft,


What is data structure in c language?

0 Answers  


What is a good data structure to use for storing lines of text?

0 Answers  


What is the meaning When we write "#include" what is # and what does include does there???

22 Answers   HCL, Wipro,


write a program which counts a product of array elements lower than 10.

1 Answers  


Categories