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 |
What is the collection of communication lines and routers called?
What are the 5 organizational structures?
what is the function of .h in #include<stdio.h> in c ?
23 Answers HCL, IBM, Wipro,
Here is a neat trick for checking whether two strings are equal
Why do we use & in c?
Explain modulus operator. What are the restrictions of a modulus operator?
List some of the static data structures in C?
void main() { int a=1; while(a++<=1) while(a++<=2); }
please give code for this 1 2 4 7 11 16
When should the register modifier be used? Does it really help?
Explain the meaning of keyword 'extern' in a function declaration.
what is the difference between exit() and _exit() functions?