You are on page 1of 2

Subject-C Programming

Academic Year: 2022-23


Year-FE Sem-II

EXPERIMENT NO.2
Aim:
Write a program to demonstrate the concept of data-types, printf & scanf statement and sizeof
operator

Tools used: gedit, gcc, OS-Ubuntu 14.04.3 LTS

Problem Statement
Write a program to store details of a student such as 1. Roll No 2. Gender 3. mobile no 4.
weight(float). Take all the values from the user. Display value and size (bytes) of each variable.

Theory:

● What is the data type?


Data type is a keyword used to identify type of data.
Data types are used for storing the input of the program into the main memory (RAM) of
the computer by allocating a sufficient amount of memory space.

● C Programming Input Output (I/O): printf() and scanf()


i) Printf() :
printf() function is used to print the “character, string, float, integer, octal and
hexadecimal values” onto the output screen.
Syntax:
printf (“format string”, argument list);
Example:
printf(“Add=%d”, Add)

Prof. Pranali Patil Department of Computer Engineering


ii) Scanf():
scanf() function is used to read character, string, numeric data from keyboard
Syntax:
scanf (“format string”, argument list);
Example:
scanf(“%d%d”,&a,&b)
.
iii) sizeof() operator
1. sizeof operator is used to calculate the size of data type or variables.
2. sizeof operator will return the size in integer format.
3. sizeof operator syntax looks more like a function but it is considered as an
operator in c programming
Example:
printf("size of int is %d\n",
sizeof(int));

Conclusion: Hence we studied the concept of data-types of variable, printf, scanf and sizeof () operator.

Prof. Pranali Patil Department of Computer Engineering

You might also like