Professional Documents
Culture Documents
Basics of C Programming
Basics of C Programming
PROGRAMMING
LEARNING OBJECTIVES
to familiarize ourselves with the basic knowledge of programming in C.
learn about the various constructs of C such as identifiers and keywords,
data types, constants, variables, input and output functions, and
pointers.
Syntax:
Example:
STRUCTURE OF A C
PROGRAM
contains one or more functions
where a function is defined as a group of statements
that perform a well-defined task.
The main() function is the most important function
and is a part of every C program. The execution of a
C program begins with this function.
Note that programmers can choose any name for
functions. It is not mandatory to write Function1,
Function2, etc., with an exception that every program
must contain one function that has its name as
main().
printf("%8f", x);
Output:
Click icon to add picture
WRITE A PROGRAM
THAT WILL INPUT ADD
TWO INTEGERS AND
DISPLAY THE SUM
Output
Click icon to add picture
Output:
Click icon to add picture
ACTIVITY3
Click icon to add picture
WRITE A PROGRAM
THAT WILL ACCEPT
TWO INTEGERS
AND DISPLAY THE
SUM, DIFFERENCE,
AND PRODUCT.
Output:
Click icon to add picture
WRITE A PROGRAM
THAT WILL ASK
FOR THE NAME
AND DISPLAY THE
NAME AND A
GREETING
Output:
TRY THIS!
SAMPLE 1:
WRITE A PROGRAM TO CALCULATE
THE AREA OF A CIRCLE.
code output
#include <stdio.h>
#include <stdlib.h>
int main()
{
float radius;
double area;
system("cls");
printf("\n Enter the radius of the circle : ");
scanf("%f", &radius);
area = 3.14 * radius * radius;
printf(" \n Area = %.2f", area);
return 0;
}