0% found this document useful (0 votes)
11 views22 pages

C Basics Training Notes

The document provides an overview of the C programming language, including its history, features, and basic structure. It covers essential concepts such as keywords, identifiers, variables, constants, data types, and input/output functions, along with example programs. Additionally, it includes practice exercises for programming skills development.

Uploaded by

selvarani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views22 pages

C Basics Training Notes

The document provides an overview of the C programming language, including its history, features, and basic structure. It covers essential concepts such as keywords, identifiers, variables, constants, data types, and input/output functions, along with example programs. Additionally, it includes practice exercises for programming skills development.

Uploaded by

selvarani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Basics of C Language

By
Mrs.V.Selvarani, M.Sc.,M.Phil.,NET.,
Assistant Professor & Head
Department of Computer Science
G.Venkataswamy Naidu College
Kovilpatti.
History of C
 Developed by Dennis Ritchie at Bell Labs in 1972
 Based on BCPL and B languages
 Designed for UNIX Operating System
 ANSI C standardized in 1989
 Mother language of many modern programming languages
Features of C
Structure of a C Program
Compilation & Execution Process
Keywords
Keywords in the C programming language are a set of predefined,
reserved words that have special meanings to the compiler.
Identifiers
 Names given to variables, functions, arrays, etc.
 Rules: Must begin with a letter/underscore, case sensitive
Variables
 A variable is a named storage location in memory used to
hold data
 Declaration: int age; Initialization: int age = 25;
 Types: int, float, char, double
 Example: int roll=101; float marks=89.5; char grade='A';
Constants
Constants are fixed values that do not change during the
execution of a program.
Data Types
Data types define the type and size of data that a variable can
hold. They inform the compiler how to interpret the data stored
in memory and what operations can be performed on it.
Input and Output Functions
Programs for int Datatypes
#include <stdio.h>
int main()
{
int var = 22;
printf("var = %d", var);
return 0;
}
Output
?
Programs for Char & Float Data types
#include <stdio.h>
int main()
{
char ch = 'A';
float val = 12.45;
printf("ch = %c", ch);
printf("The character '%c' has an ASCII value of %d.\n", ch,
ch);
printf("val = %f", val);
return 0;
}
Output
?
Programs for Double Datatypes
#include <stdio.h>
int main()
{
double val = 1.4521;
printf("val = %lf", val);
return 0;
}

Output
?
Programs for Size of Datatypes
#include <stdio.h>
int main()
{
printf("The size of int: %d\n", sizeof(int));
printf("The size of char: %d\n", sizeof(char));
printf("The size of float: %d\n", sizeof(float));
printf("The size of double: %d“, sizeof(double));
return 0;
}

Output
?
printf() and scanf()
#include <stdio.h>
int main()
{
int a, b, sum;
printf("Enter two integers: ");
scanf("%d %d", &a, &b);
sum = a+b;
printf("%d + %d = %d", a, b, sum);
return 0;
}
Output
?
getchar() and putchar() Function
 getchar( ) function is used to read one character at a time
from the key board.
 putchar( ) function is used to display one character at a
time on the monitor.
Program
int main()
{
char ch;
printf("Enter Char:");
ch=getchar();
printf("Output:");
putchar(ch);
} Output
?
gets() and puts() Function
 gets( ) function is used to read a string of characters including
white spaces
 puts() is a function used to display strings on screen.
Program
#include <stdio.h>
int main()
{
char ch[20];
printf("Enter Char:");
gets(ch);
//fgets(ch, sizeof(ch), stdin);
printf("Output:");
puts(ch);
return 0; Output
} ?
Program Practice
1. Write a Program to Swap Two Numbers.
2. Write a Program to Multiply Two Numbers.
3. Write a Program to Compute Quotient and
Remainder.
4. Write a program to read three integer number and
print the sum of it.
5. Write a program to read three float number and print
the sum of it.
6. Write a program to read the sides of rectangle and
print the area and perimeter of rectangle.
7. Write a program to read the radius of circle and
print the area and perimeter of circle.

You might also like