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
Explain how do you list a file’s date and time?
What are the features of c languages?
Write a program to print ASCII code for a given digit.
Write a program to print fibonacci series using recursion?
What is the use of getch ()?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What is void main ()?
What is a double c?
What is the difference between a string and an array?
What is storage class?
Explain what is the advantage of a random access file?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
What does %c mean in c?
What are the rules for the identifier?
What happens if header file is included twice?