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

How can you find the day of the week given the date?

0 Answers  


What's the difference between a linked list and an array?

14 Answers  


What is the output of below code? main() { static in a=5; printf("%3d",a--); if(a) main(); }

4 Answers   Infosys, TCS,


What are the different types of C instructions?

0 Answers   InterGraph,


What is ctrl c called?

0 Answers  






Describe the modifier in c?

0 Answers  


Is printf a keyword?

0 Answers  


why we need function pointers?

3 Answers  


write a c program to store and print name,address,roll.no of a student using structures?

7 Answers  


#define MAX 3 main() { printf("MAX = %d \n",MAX ); #undef MAX #ifdef MAX printf("Vector Instituteā€); #endif

4 Answers   IBM, Vector,


Is python a c language?

0 Answers  


Write a program to print all permutations of a given string.

0 Answers   JPMorgan Chase,


Categories