TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Function with no Arguments but Return Value In C
Ashish Srivastava
Apr 21
2016
Code
39.2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
/*C program to check whether a number entered by user is prime or not using function with no arguments but having return value */
#include <stdio.h>
#include <conio.h>
int
input();
void
main(){
int
num,i,flag = 0;
num=input();
/* No argument is passed to input() */
for
(i=2; i<=num/2; ++i){
if
(num%i==0){
flag = 1;
break
;
}
}
if
(flag == 1)
printf(
"%d is not prime"
,num);
else
printf(
"%d is prime"
, num);
getch();
}
int
input(){
/* Integer value is returned from input() to calling function */
int
n;
printf(
"Enter positive integer to check:\n"
);
scanf(
"%d"
,&n);
return
n;
}
Function with no arguments
return value
C