Write a c program using for loop in switch case?



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

Post New Answer

More C Interview Questions

Can an array be an Ivalue?

0 Answers   EXL,


What is openmp in c?

0 Answers  


What is file in c preprocessor?

0 Answers  


What is wrong with this initialization?

0 Answers  


Why cann't whole array can be passed to function as value.

1 Answers  






progrem to generate the following series 1 12 123 1234 12345

6 Answers   HCL, Wipro,


Write a program to generate prime factors of a given integer?

2 Answers  


What is structure in c definition?

0 Answers  


What does 3 periods mean in texting?

0 Answers  


how can you print&scan anything using just one character? :) HINT: printf,scanf similer

2 Answers  


How do you convert strings to numbers in C?

0 Answers  


Write a program that accepts a string where multiple spaces are given in between the words. Print the string ignoring the multiple spaces. Example: Input: “ We Are Student “ Output: "We Are Student"

1 Answers  


Categories