Write a program to convert C to C++. - Prime Number
AIM:
Write
a program to covert C to C++ for Prime Number.
SOURCE
CODE:
IN
C++:
#include<iostream>
using namespace std;
int main(){
int
i,n,f_count=1;
cout<<"\n
enter the value of n:";
cin>>n;
for(i=1;i<n;i++){
f_count++;
}
}
if(f_count==2) {
cout<<"\n
it is a prime number";
}
else{
cout<<"\n
it is not a prime number";
}
}
IN C:
#include<stdio.h>
main() {
int i,n,f_count;
printf("Enter the value of
n:");
scanf("%d",n);
for(i=1;i<n;i++){
if(n%i==0)
{
f_count++;
}
}
if(f_count==2) {
printf("it
is a prime number");
}
else {
printf("it
is not a prime number");
}
}
Labels: oop through c++ lab
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home