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 scanf() programs

Input an unsigned integer value using scanf() in C



Here, we are going to learn how to input an unsigned integer values using scanf() function in C programming language?
Submitted by IncludeHelp, on September 12, 2018

Here, we have to declare an unsigned integer variable and read its value using scanf() function in C.

The data type to declare an unsigned integer is: unsigned int and the format specifier that is used with scanf() and print() for unsigned int type of variable is "%u".

Program:

#include <stdio.h>

int main(void) 
{
	unsigned int value;

	printf("Enter an unsigned int value: ");
	scanf("%u", &value);
	printf("value: %u\n", value);

	//input again 
	printf("Enter an unsigned int value again: ");
	scanf("%u", &value);
	printf("value: %u\n", value);

	//input again
	printf("Enter an unsigned int value again: ");
	scanf("%u", &value);
	printf("value: %u\n", value);

	return 0;
}

Output

Enter an unsigned int value: 123712
value: 123712
Enter an unsigned int value again: -1
value: 4294967295
Enter an unsigned int value again: 25501
value: 25501

Note: See the input second and its result, when we provide -1 to an unsigned integer value, it assigns "maximum value to an unsigned int" to the variable.






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.