0% found this document useful (0 votes)
39 views1 page

Printf Scanf: Enter The Radius

This document contains code for 3 functions: 1. An area() function that calculates and prints the area of a circle given a radius input by the user. 2. A prime() function that checks if a positive integer entered by the user is prime by testing for divisibility, and prints the result. 3. A main() function that checks if a number entered by the user is prime by counting the number of factors, and prints the result.

Uploaded by

VenugopalReddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views1 page

Printf Scanf: Enter The Radius

This document contains code for 3 functions: 1. An area() function that calculates and prints the area of a circle given a radius input by the user. 2. A prime() function that checks if a positive integer entered by the user is prime by testing for divisibility, and prints the result. 3. A main() function that checks if a number entered by the user is prime by counting the number of factors, and prints the result.

Uploaded by

VenugopalReddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

include<stdio.

h>
void area();
void main()
{
area();
}

// Prototype Declaration

void area()
{
float area_circle;
float rad;
printf("\nEnter the radius : ");
scanf("%f",&rad);
area_circle = 3.14 * rad * rad ;
printf("Area of Circle = %f",area_circle);
}
#include <stdio.h>
void prime();
int main(){
prime();
//No argument is passed to prime().
return 0;
}
void prime(){
/* There is no return value to calling function main(). Hence, return type of
prime() is void */
int num,i,flag=0;
printf("Enter positive integer enter to check:\n");
scanf("%d",&num);
for(i=2;i<=num/2;++i){
if(num%i==0){
flag=1;
}
}
if (flag==1)
printf("%d is not prime",num);
else
printf("%d is prime",num);
}
#include <stdio.h>
main() {
int n, i, c = 0;
printf("Enter any number n:");
scanf("%d", &n);
/*logic*/
for (i = 1; i <= n; i++) {
if (n % i == 0) {
c++;
}
}
if (c == 2) {
printf("n is a Prime number");
}
else {
printf("n is not a Prime number");
}
return 0;
}

You might also like