Here are few very simple and basic C language programs with C programming examples that you will use to understand the basics very easily.
Write
a C programme to calculate area of a rectangle :
#include<stdio.h>
int main(){
Int l, b, area;
printf(“Enter length and breadth
of a rectangle \n”);
scanf(“%d %d”, &l, &b);
area = l *b;
printf(“Area of rectangle is %d
\n”, area);
return 0;
}
Write
a C program to calculate area of a circle :
#include<stdio.h>
int main(){
float r, area;
printf(“Enter the radius of the
circle \n”);
scanf(“%f”, &r);
area = 3.14*r*r;
printf(“Area of circle is %f
\n”, area);
return 0;
}
Write
a C program to calculate simple intrest (SI) :
#include<stdio.h>
int main(){
float p, r, t , si;
printf(“Enter the values of p,
r, and t respectively \n”);
scanf(“%f %f %f”, &p, &r,
&t);
si= p * r * t /100;
printf(“Simple interest is %f
\n”, si);
return 0;
}
Comments
Post a Comment