untitled
My sites
Home
Plus One
Plus two
Your Voice
About Author
Brother's Site
First Home
Kerala Links
Indian Links
Indian Fonts
Site Submission
Thss,Mlpy
Plus One Programs
Index of programs:Set 4
Prime number Generation 1
Prime number Generation 2
Prime number Generation 3
Factorial of number using recursion
Find secondlargest and secondsmallest
<<
Previous
Next Page
>>
Program1:
#include
#include
#include
/* Author : Rohith.R Email : rrohithr@gmail.com Category : Begineer Program : To find n prime numbers Meant For: Plus One students,Kerala */ void main() { long int pri,n,li; clrscr(); cout<<"Enter limit of Prime generations:"; cin>>li; pri=2; int c=0; while(c
sqrt(pri)) { cout<
Program 2:
#include
#include
/* Author : Someone Email : _____@_____.com Category : Begineer Program : To find whether number prime or not Meant For: Plus One students,Kerala Source : Internet */ void main() { int n; cout<<"Enter number"; cin>>n; int x=2; loop :if(x<=n/2) { if(n%x==0) { cout<<"Its composite"; goto end; } else { x=x+1; goto loop; } } else cout<<"Its prime"; end: cout<<"\n Press any key to continue"; getch(); }
Program 3:
#include
#include
/* Author : ________ Email : ______@______.com Category : Begineer Program : To find whther a number is prime or not Meant For: Plus One students,Kerala Source : Internet */ int prime(int n) { int i; if (n % 2 == 0) return (n==2); if (n % 3 == 0) return (n==3); if (n % 5 == 0) return (n==5); for (i=7; i*i <= n; i+=2) if (n % i == 0) return 0; return 1; } void main(void) { int i, n; n = 1000; clrscr(); cout << "ENTER THE NUMBER :-"; cin >> i; if (prime(i)) cout <<"\n THE NUMBER IS PRIME."; else cout << "\nTHE NUMBER IS NOT PRIME."; getch(); }
Program 4:
/* Author : Rohith.R Email : rrohithr@gmail.com Category : Begineer Program : To find factorial of number using recursion Meant For: Plus One students,Kerala Explaination :Each number added to stack and atlast result is popped */ unsigned long int fact(int n) { unsigned long int f=1; if(n==1||n==0) return(1); else f=n*fact(n-1); return(f); } #include
#include
void main() { int num; clrscr(); unsigned long int fact(int),f=1; cout<<"Enter number"; cin>>num; if(num<0) cout<<"Factorial not defined"; else { f=fact(num); cout<<"Factorial of number is"<
Program5:
#include
#include
/* Author : Rohith.R Email : rrohithr@gmail.com Category : Begineer Program : To find second largest and second smallest Meant For: Plus One students,Kerala */ // SORTING AN ARRAY IN ASCENDING ORDER AND FINDING SECOND LARGEST AND SMALLEST// void main() { clrscr(); cout<<"\n\nEnter number of numbers you want to enter:"; unsigned long int n; F: cin>>n; if(n<=0) { cout<<"\n\nZero and negative not allowed"; goto F; } float l[50]; float c[50]; for(int i=1;i<=n;i++) { cout<<"\n\nEnter number: "; cin>>l[i]; } for(i=1;i<=n-1;i++) { for(int j=1;j<=n-i;j++) { if(l[j]>l[j+1]) { c[j] =l[j]; l[j]=l[j+1]; l[j+1]=c[j]; } } } clrscr(); cout<<"\n ---------------------------------------------------------\n"; cout<<"-----------------------------------------------------------"; for(i=1;i<=n;i++) { cout<<"\n\n"; cout<<" "<
n) cout<<"\n\n\nStatus :No second smallest"; else cout<<"\n\n\nStatus :Second smallest is"<
<<
Previous Page
Next Page>>
Web Hosting
·
Blog
·
Guestbooks
·
Message Forums
·
Mailing Lists
Easiest Website Builder ever!
·
Build your own toolbar
·
Free Talking Character
·
Email Marketing
powered by
bravenet.com