Immanuel Training Institute proudly presents free software courses
To get certificate Contact: iits.certificate@gmail.com
CHAPTER 1 Introduction and structure of C program
CHAPTER 2 Data types,Constants, Variables and I/O Statements
CHAPTER 3 Operators and Expressions
CHAPTER 6 String Manipulations
CHAPTER 8 Structure,Unions and Enumerated Data types
CHAPTER 2
VARIABLE:
A variable is
a name of the memory location. It is used to store data. Its value can be
changed, and it can be reused many times. It is a way to represent memory
location through symbol so that it can be easily identified.
Variable
declaration:
<data_type> variable1,variable2......;
Ex:
int a;
float b;
char c;
char c[10];
double d;
KEYWORDS:
Keywords
are predefined, reserved words in C that are already defined by the c compilers.
These are used to do functionality of C language. They are all having the
special meanings
There
are 32 keywords in C language,
|
auto |
double |
int |
struct |
|
break |
else |
long |
switch |
|
case |
enum |
register |
typedef |
|
char |
extern |
return |
union |
|
continue |
for |
signed |
void |
|
do |
if |
static |
while |
|
default |
goto |
sizeof |
volatile |
|
Const |
float |
short |
unsigned |
CONSTANTS:
Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal.
Ex:
int a=10;
float b=10.1;
char c=’a’;
char c[10]=”hello”;
DATA TYPES:
Data types nothing but Keywords, which specifies, what type of data can be stored in the given location.
- Basic: int, char, float, double
- Derived: array, pointer, structure, union, enum
- User defined: typedef
- Void data type
Basic data types with its memory size and
range according to the 32-bit architecture:
|
Data
type |
Memory
size |
Range |
|
char |
1
byte (8
bits) |
=
-27 to (27)-1 =
−128 to 127 |
|
int
|
2
bytes (16
bits) |
=
-215 to (215)-1 =
−32,768 to 32,767 |
|
float |
4
bytes (32
bits) |
=
-231 to (231)-1 = -2,147,483,648 to
2,147,483,647 |
|
double |
8
bytes (64
bits) |
-263
to (263)-1 |
STANDARD INPUT FUNCTIONS:
1.scanf():
It is used to get input from user.
syn:
scanf("control_string",&var1,&var2,......);
ex:
scanf("%d",&a);
STANDARD OUTPUT FUNCTIONS:
2.printf();
It is used to print values, messages.
syn:
printf("control_string", var1,var2,.........);
ex:
printf("%d",a);
CONTROL STRING OR FORMAT SPECIFIER:
control string Data type
2. %c char
3. %s char(string)
4. %f float
5. %ld double
EXAMPLE PROGRAMS:
1. Write a program to display your name?
#include<stdio.h>
#include<conio.h>
void main()
{
char a='A';
char name[10];
clrscr();
printf("Enter the name:");
scanf("%s",name);
printf("This is what you have entered\n");
printf("%c\t%s",a,name);
getch();
}
2. Write a program to add two numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
a=10;
b=10;
c=a+b;
printf("The addition value is %d",c);
getch();
}
3. Write a program to divide three numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
float d;
clrscr();
printf("Enter any three values:");
scanf("%d%d%d",&a,&b,&c);
d=(a+b+c)/3.0;
printf("The average value of given three nos. is %f",d);
getch();
}
TN 10TH SAMACHEER MATHS EXERCISE 2.5 SOLUTIONS