Showing posts with label CPP PROGRAMS. Show all posts
Showing posts with label CPP PROGRAMS. Show all posts

Tuesday, September 6, 2011

PRIME-METHOD1

#include<iostream.h>
#include<conio.h>
void main()
{
int i=1,k=0,n;
clrscr();
cout<<"enter the number";
cin>>n;
while(i<=n)
{
if(n%i==0)
k=k+1;
i++;
}
if(k==2)
cout<<"prime number";
else
cout<<"not a prime number";
getch();
}

OUT PUT












If U LIKE THE POST FOLLOW THE BLOG

STRING COPY- EXAMPLE

I#include<stdio.h>
#include<conio.h>
void main()
{
char str1[] = "indian box";
char str2[20];
strncpy(str2,str1,8);
printf("%s",str2);
getch();
}

OUT PUT:






If U LIKE THE POST FOLLOW THE BLOG

PROGRAM USING FUNCTION

I#include<stdio.h>
void display(int(*ff)());
void main()
{
int show();
int (*f)();
f = show;
display(f);
getch();
}
void display(int(*ff)())
{
(*ff)();
}
int show()
{
clrscr();
printf("india");
}
f U LIKE THE POST FOLLOW THE BLOG