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
What are local static variables? How can you use them?
What do you mean by recursion in c?
Are there any problems with performing mathematical operations on different variable types?
What are the similarities between c and c++?
Does c have function or method?
What are directives in c?
What is a double c?
What is methods in c?
what are non standard function in c
Tell us two differences between new () and malloc ()?
Function calling procedures? and their differences? Why should one go for Call by Reference?
What is equivalent to ++i+++j?
Why c language is called c?
What are nested functions in c?
Why do we need volatile in c?