Upcoming SlideShare
×

# Assignment no 5

579 views

Published on

c++ assignment

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
579
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
6
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Assignment no 5

1. 1. Assignment no 5 1) WAP to find the factorial value of any no. entered through the keyboard.flowchart:
2. 2. Program://c++ program to find the factorial value#include<iostream.h>#include<conio.h>void main( ){clrscr( );int a,f=1;cout<<”Enter any number:”<<endl;cin>>a;for( int i=1; i<=a; i++){f=f*i;}cout<<”Factorial of the entered number=”<<f;getch();}
3. 3. output:Enter any number:5Factorial of the entered number= 120 2) WAP to reverse any given integer no.
4. 4. Program://c++ program to reverse the entered no#include<iostream.h>#include<conio.h>void main( ){clrscr( );int r,n,a=0;cout<<”Enter any three digit number:”<<endl;cin>>n;cout<<”Reverse of the entered number is:”<<endl;while(n!=0){r=n%10;
5. 5. a=a*10+r;n=n/10;cout<<r;}getch();}Output:Enter any three digit number:123Reverse of the entered number is:321 3) WAP to check whether the given no is prime or not..
6. 6. Program://c++ program to check whether the given no is prime or not
7. 7. #include<iostream.h>#include<conio.h>void main( ){clrscr( );int a,c=0;cout<<”Enter any number:”<<endl;cin>>a;for( int i=1;i<=a;i++){if(a%1==0){c++;}}if(c==2){cout<<”Entered number is prime”<<endl;}
8. 8. else{cout<<”Entered number is not prime”<<endl;}getch();}OutputEnter any number:5Entered number is prime