WAP in C for function without argument and return type?

#include<stdio.h>
#include<conio.h>
int prime();

int main()
{
int n, i, flag=0;
clrscr();
// no argument is passed to the function
// the value returned from the function is assigned to n
n = prime();
for(i=2; i<=n/2; ++i)
{
if(n%i==0)
{
flag = 1;
break;
}
}
if (flag == 1)
printf(“%d is not a prime number.”, n);
else
printf(“%d is a prime number.”, n);
getch();
return (0);
}

// prime() function returns integer entered by the user
int prime()
{
int n;
printf(“Enter a positive integer: “);
scanf(“%d”,&n);
return(n);
}

Output :-

noaguwithret

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s