c-programs
c-programs
C-programs(1-6) - 2018-2019
1. Write a C Program to read radius of a circle and to find area and circumference
//C program to find the area of a circle and circumference of circle
#include<stdio.h>
void main()
{
float r;
printf("Enter radius:");
scanf("%f",&r);
2. Write a C Program to read three numbers and find the biggest of three
#include <stdio.h>
int main()
{
int A, B, C;
return 0;
}
int main ()
{
float val1, val2;
val1 = 1.6;
Downloaded by Ok Bro ([email protected])
lOMoARcPSD|56042252
val2 = 1.2;
return(0);
}
#include <math.h>
#include <stdio.h>
int main()
{
int n, i, flag = 1;
if (n <= 1)
flag = 0;
if (flag == 1) {
printf("%d is a prime number", n);
}
else {
printf("%d is not a prime number", n);
}
return 0;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i, j, count;
clrscr();
printf("Prime no.series\n");
printf("Enter any number\n");
scanf("%d", &n);
printf("The prime numbers between 1 to %d\n",n);
for(i = 1; i <= n; i++)
{
count = 0;
for(j = 1; j <=i; j++)
if(i % j == 0)
{
count++;
}
if(count == 2)
{
printf("%d\t", i);
}
}
getch();
}
6. Write a C Program to read a number, find the sum of the digits, reverse the number and
check it for palindrome
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( )
int num,sum=0,rev=0,d;
printf("Enter the number: ");
scanf("%d",&n);
while(num){
d=num%10;
num=num/10;
sum=sum+d;
rev=rev*10+d;
}