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

why r u join this company? give solid resons.

16 Answers   IBM, Infosys, TCS,


write a program to convert a expression in polish notation (postfix) to inline (normal)

0 Answers   Siemens,


What are global variables and how do you declare them?

0 Answers  


What oops means?

0 Answers  


Is exit(status) truly equivalent to returning the same status from main?

0 Answers  






What are the scope of static variables?

0 Answers  


What is difference between structure and union?

0 Answers  


write a c program to find largest of three numbers using simple if only for one time.

1 Answers  


Describe the steps to insert data into a singly linked list.

0 Answers  


What is binary tree in c?

0 Answers  


What is the stack in c?

0 Answers  


What is a constant and types of constants in c?

0 Answers  


Categories