4. Set the Bit in an 8-bit Register

Back To All Submissions
Previous Submission
Next Submission

Code

#include <stdio.h>
#include <stdint.h>

void setbit(uint8_t *reg,uint8_t pos){
	*reg |= (1 << pos);
}


int main() {
	uint8_t reg, pos;
	scanf("%hhu%hhu", &reg, &pos);
	setbit(&reg, pos);
	printf("%u", reg);

	
}

Solving Approach
 

 

 

Was this helpful?
Upvote
Downvote