Cost to fence the park outside
#include<stdio.h>
int main(){
int l,b,w,c,area1,area2;
scanf("%d%d%d%d",&l,&b,&w,&c);
area1=l*b;
area2=(l+2*w)*(b+2*w);
printf("%d",(area2-area1)*c);
return 0;
}
Area of circle
#include<stdio.h>
int main(){
int r;
float area;
scanf("%d",&r);
area=3.14*r*r;
printf("%.2f",area);
return 0;
}
FAHRENHEIT TO CELSIUS
#include<stdio.h>
int main(){
int a;
float b;
scanf("%d",&a);
b=(a-32)*5/9.0;
printf("%.2f",b);
return 0;
}
Simple interest
#include<stdio.h>
int main(){
int p,t,r;
scanf("%d%d%d",&p,&t,&r);
printf("%d",p*t*r/100);
}
Diagonals of polygon
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
printf("%d",n*(n-3)/2);
}
Area of triangle
#include<stdio.h>
#include<math.h>
int main(){
int a,b,c;
float s,area;
scanf("%d%d%d",&a,&b,&c);
s=(a+b+c)/2.0;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("%.2f",area);
return 0;
}
Average of two numbers
#include<stdio.h>
int main(){
int a,b;
float s;
scanf("%d%d",&a,&b);
s=(a+b)/2.0;
printf("%.4f",s);
return 0;
}
Find ASCII value of a character
#include<stdio.h>
int main(){
char s;
scanf("%c",&s);
printf("%d",s);
return 0;
}
program to multiply two floating point numbers
#include<stdio.h>
int main(){
float a,b;
scanf("%f%f",&a,&b);
printf("%.2f",a*b);
return 0;
}
Multiplication
#include<stdio.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
printf("%d",a*b);
return 0;
}
Division
#include<stdio.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
printf("%d",a/b);
return 0;
}
Modulus
#include<stdio.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
printf("%d",a%b);
return 0;
}
Take input and print
#include<stdio.h>
int main(){
char a[30];
scanf("%[^\n]s",a);
printf("%s",a);
return 0;
}
Adding Two numbers
#include<stdio.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
printf("%d",a+b);
return 0;
}
program to find maximum hand shakes
#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
printf("%d",a*(a-1)/2);
return 0;
}
Subract product ans sum of digits
#include<stdio.h>
int main(){
int a,sum=0,prod=1,r,temp;
scanf("%d",&a);
temp=a;
while(temp){
r=temp%10;
sum+=r,prod*=r;
temp/=10;
}
printf("%d",prod-sum);
return 0;
}
Spy number
#include<stdio.h>
int main(){
int a,sum=0,prod=1,r,temp;
scanf("%d",&a);
temp=a;
while(temp){
r=temp%10;
sum+=r,prod*=r;
temp/=10;
}
if(sum==prod)
printf("Spy Number");
else
printf("Not Spy Number");
return 0;
}
Neon number
#include<stdio.h>
int main(){
int a,sum=0,temp,r;
scanf("%d",&a);
temp=a*a;
while(temp){
r=temp%10;
sum+=r;
temp/=10;
}
if(sum==a)
printf("Neon Number");
else
printf("Not Neon Number");
return 0;
}
Sum of given numbers
#include<stdio.h>
int main(){
int n,a,b;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d",&a,&b);
printf("%d\n",a+b);
}
return 0;
}
Prime number
#include<stdio.h>
int main(){
int n,count=0;
scanf("%d",&n);
for(int i=1;i<n;i++)
if(n%i==0)
count++;
if (count==1)
printf("prime");
else
printf("not a prime");
return 0;
}
perfect square root or not
#include<stdio.h>
#include<math.h>
int main(){
int n,a;
scanf("%d",&n);
a=int(sqrt(n));
if (n==a*a)
printf("True");
else
printf("False");
return 0;
}