- /*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;
- }
Thursday, 21 December 2017
Function with no Arguments but Return Value In C
Subscribe to:
Post Comments (Atom)
Upload valid file in C#
protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile) { try { Dictionary<string, byte[]...
-
Setting Header Programatically You can also set the cache headers programmatically. This can be useful for generated content and allows m...
-
CREATE TABLE dbo.M_Bank ( ID INT IDENTITY NOT NULL, MB_NAME NVARCHAR (50), MB_SNAME NVARCHAR (20), MB_ADDUSER ...
-
SELECT distinct(volume_mount_point), total_bytes/1048576 as Size_in_MB, total_bytes/1048576/1024 as Size_in_GB, available_bytes/1048576 ...
No comments:
Post a Comment