Skip to main content

C Programming Examples | C Examples | C programming Exercises, Practice, Solution

C practice programs

 

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

Popular posts from this blog

What is C language | C language uses | Topics of C language

In this blog I will tell you the most common uses of C language Programming and the Topics that I will cover in my Tutorial of C Language What are the uses of c language ? C language is used to code a wide variety of advance systems that are very fast executed and works efficiently . C was developed for the development of unix operating system (OS). Major parts of windows , linux , and other operating systems are written using C language. C is widely used to write device driver programs such as driver programs for hardwares like tablets, printers,routers , keyboard and mouses etc . C language is used to program embedded system where requirement of execution speed is very faster and also it has to be executed in a limited memory. These type of programs are written is C language to archive the faster execution in limited memory. the devices for which these type of programs are written can be Microwave ovens, Cameras, smart washing machines , refrigrators etc. Apart from that C language i...

Structure of C Program with Example | C Programming

In this post I will tell you the basic structure of C program  with example in C programming in very simple words. Our First C program : # include<stdio.h> int main() {            printf("Hello World");            return 0; } save te above program with file name "First.c" Note : Every C language file should be saved using .C extention name. Basic structure of a C program : All C programs have to follow a basic structure. The execution of a C program starts from the main() function. The C compiler starts execution from the main() function and executes each statement written inside the main() function line by line. Each instruction of a C program should be terminated by a semicolon ( ; ) i.e. every line of a C program ends with the semicolon ( ; ). 1.      Every program execution starts from the main( ) function. 2.   ...