write a program using switch case to print tha number is prime or not
Answers
Toggle navigation
Write a program using a switch statement to check whether a number given by the user is odd or even
Views 2520
About:
Write a program using a switch statement to check whether a number given by the user is odd or even
Program:
#include
int main()
{
int n;
printf("\n Enter the number:");
scanf("%d", &n);
switch(n%2)
{
case 0: printf("\n EVEN");
break;
case 1: printf("\n ODD");
break;
}
getch();
return 0;
}
Output:
Output 1:
Enter the number:12
EVEN
Output 2:
Enter the number:11
ODD
Explanation:
None
Share Me:
C Program List
276. Write a program that checks whether a character entered by the user is a vowel or not (using switch case)
277. Write a program that asks the user to enter some numbers and then find their average using counter-based loop.
278. Write a program that prints the sum of digits of a number.
279. Write a program to print the sum of the series 1+2+3+4+... up to n terms.
280. Write a program that prints the sum of digits of a number using for loop.
281. Write a program to solve the following problem- Euler's number e is used as the base of natural logarithms. It may be approximated using the following formula: where n is sufficiently large. Write a program that approximates e using a loop that terminates when the difference between the two successive values of e is less than 0.0000001.
282. Write a program that reads a list of test scores and calculate their average. An input of -99 for a score denotes end-of-data for the user
283. Write a program that reads a list of test scores and calculate their average. An input of EOF(by pressing CTRL+Z) for a score denotes end-of-data for the user
284. Write a program to find the factorial of a number using for loop
285. Write a program to check whether a number is a prime number or not.(Using While loop)
286. Write a program that prints out a multiplication table.
287. Write a program for printing prime numbers between 1 and 100.
288. Write a program to compute the square root of a given number (without using sqrt() function of the math library).
289. Get the lengths of three sides of a triangle. Check whether the triangle can be formed or not. If possible then classify the triangle as equilateral, isosceles or scalene. Otherwise, if the triangle cannot be formed give the user a chance to re-enter the lengths of the sides or terminate the program.
290. Write a program that illustrates the concept of variable length array.
291. Write a program that will compute the binary equivalent number of a decimal number and print it as output.
292. Write a program that will compute the Fibonacci series and print it as output.
293. Write a program that will search and find out the position where the given key element exist in a user chosen array and print it as output.
294. Sort array elements in c programming language
295. Write a program that uses the binary search algorithm to find out the position where the given key element exist in a user chosen array and print it as output.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
Home About Terms and Conditions Ads
© 2017 atnyla All rights reserved