Showing posts with label check. Show all posts
Showing posts with label check. Show all posts
Wednesday, February 18, 2015
Java program to check whether a number is prime or not

class prime
{
public static void main(String...s)
{
int n,i;
n=Integer.parseInt(s[0]);
for(i=2;i<n;++i)
{
if(n%i==0)
break;
}
if(i==n)
System.out.println("
Number is prime");
else
System.out.println("
Number is not prime");
}
}
Wednesday, February 11, 2015
C program to check given alphabate is vowel or not using switch case

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Enter an alphabate:");
scanf("%c",&ch);
switch(ch)
{
case a:
case A:
case e:
case E:
case i:
case I:
case o:
case O:
case u:
case U:
printf("The alphabate is vowel");
break;
default: printf("The alphabate is not vowel");
}
getch();
}
Subscribe to:
Posts (Atom)