Write a c program using for loop in switch case?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is merge sort in c?

824


Explain data types & how many data types supported by c?

813


What are examples of structures?

785


Is using exit() the same as using return?

913


Is c is a middle level language?

794


What does c mean in standard form?

830


Explain the bubble sort algorithm.

847


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

1021


What is variable and explain rules to declare variable in c?

778


What is a macro?

861


why we wont use '&' sing in aceesing the string using scanf

2057


What is dynamic variable in c?

776


What is function definition in c?

776


Using which language Test cases are added in .ptu file of RTRT unit testing???

3981


What does 2n 4c mean?

968