Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » C programs » C typedef programs

Example of typedef in C language



Here, we will learn how to use typedef to provide name to a data type? Here, we are defining name for an int, a char and a float.
Submitted by IncludeHelp, on September 06, 2018

What is typedef?

typedef is a keyword in C programming language, it is used to define a name to the data type, for example, if you want to define "I" for an int variable, or "UC" for unsigned char etc.

Syntax:

 typedef name datatype_name;

Example:

#include <stdio.h>

typedef int I;
typedef char C;
typedef float F;

int main()
{
	I intVar = 10;
	C charVar = 'X';
	F floatVar = 10.23f;
	
	printf("intVar = %d\n",intVar);
	printf("charVar = %c\n",charVar);
	printf("floatVar = %f\n",floatVar);
	
	return 0;
}

Output

intVar = 10
charVar = X
floatVar = 10.230000





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates



© https://www.includehelp.com (2015-2018), Some rights reserved.