- /*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[]>...
-
CREATE TAblE #temp ( T_Name VARCHAR(50), T_Times BIGINT ) INSERT INTO #temp(T_Name,T_Times) VALUES ('ASHISH',4) IN...
-
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 ...
No comments:
Post a Comment