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 the use of #include in c?
Are global variables static in c?
What is self-referential structure in c programming?
What is logical error?
Is a pointer a kind of array?
Wt are the Buses in C Language
what is uses of .net
What does the characters “r” and “w” mean when writing programs that will make use of files?
Write a program to print ASCII code for a given digit.
What is static and volatile in c?
What is a far pointer in c?
How can I write functions that take a variable number of arguments?
What is the use of typedef in c?
What is hashing in c?
What is an auto variable in c?