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 is merge sort in c?
Explain data types & how many data types supported by c?
What are examples of structures?
Is using exit() the same as using return?
Is c is a middle level language?
What does c mean in standard form?
Explain the bubble sort algorithm.
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?
What is variable and explain rules to declare variable in c?
What is a macro?
why we wont use '&' sing in aceesing the string using scanf
What is dynamic variable in c?
What is function definition in c?
Using which language Test cases are added in .ptu file of RTRT unit testing???
What does 2n 4c mean?