C Language | If , If-else and For Loop Statements

Friday 21 December 2012


I was playing a game with some kids called "is it hot", when I thought of putting it into a program. This game is mostly played with little kids. All you have to do is assign numbers in each temperature. For example, 1=hot, 2=cold and 3=warm. It is played by saying random numbers but the kids must take note that every time you say 1 or 2 or 3 they must answer you with hot, cold or warm. If you say other numbers except the three they should say, "out of order". This is kind of game is fun if the kids are in groups because they need to work with their teams to win.

As for me, I made a program out of this game to show you how you can put up If Statement, If-else Selection Statement and For Loop Statement in one program. There are certain programs that needs a strong foundation to be more productive especially programs with a lot of selection, decision making and repetitive statements. This example I have is one of those programs. Check out the codes below.


#include<stdio.h>
#include<conio.h>

main()
{
      int a=1, b=1; 
      int count;
      
      printf("Enter how many counts: ");
      scanf("%d",&count);
      
      if(count>30) {
      printf("\nYou have exceeded the maximum input of 30");
      getch();
      return 0;
      }
   
Related Posts Plugin for WordPress, Blogger...