A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Input an unsigned integer value using scanf() in C
Q:

Input an unsigned integer value using scanf() in C

0

Input an unsigned integer value using scanf() in C

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now