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

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.   ...

What Are Variables in C language | Constants and Keywords in language

Variables are the containers in C language which are used to store data in the program. Variables are the small memory blocks which holds some values in it. Variables in c language :       What are variables in C language ?     In C language, A variable is just like a container that contains values of different data           types. A variable is an entity whose value can be change.      This means that to store any value we use variables in C language. These variables can e        imagined as the small memory blocks in which the data is stored of different types. The           variables are the one of important components of c language as it is used most                          frequently inside the programs of C language.        For Instance In our Kitchen we have differen...

What is C language | C language tutorial | C language basics

  C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972.  C is strongly associated with UNIX, as it was developed to write the UNIX operating system. C Language Tutorial : What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system. Why Learn C? It is one of the most popular programming language in the world If you know C, you will have no problem learning other popular programming languages such as Java, Python, C++, C#, etc, as the syntax is similar C is very fast, compared to other programming languages, like  Java  and  Python C is very versatile; it can be used in both applications and technologies