Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
Resource icon

Simple Number Guessing Program

[CODE lang="c" title="number.c"]#include <stdio.h>

int main(void) {
int usr_num = 0; // The Number that the User inserts
int app_num = 56; // The Number that the Program is thinking of

// Welcome Message
printf("Hey. I'm thinking of a Number. Try and guess it and I'll tell you if you're right: ");
// Receive Input for the Number
scanf("%d", &usr_num);

// Determine if the User got it right
if(usr_num == app_num) {
// Print this if they got it right
printf("Yay! You got it right!\n");
} else {
// Print this if they got it wrong
printf("Sorry. That wasn't right. The Answer was: 56\n");
}

return 0;
}[/CODE]
  • Like
Reactions: ratwolf
Author
Dan-Kode
Views
1,606
First release
Last update

Ratings

3.00 star(s) 1 ratings

Latest reviews

Line 18: printf("Sorry. That wasn't right. The Answer was: %d\n", app_num);
Back
Top Bottom