Is It Hot computer programming problem

Monday, April 20, 2009 · Posted in

This is a problem in which it includes the manipulation of loop not only loop but also the array and the nested for loop or the loop inside the another loop. This is the same with the recursion, in which there is a function inside the another function.

Problem:

Create a problem in which, the program allow the users to input a number and display the HOT for 1, LUKE for 2, WARM for 3 and if the user input a number of 4 and above and then the program will display OUT OF RANGE. Strictly use for loop.

OUTPUT:

CODE:


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

int main()
{
int x, y, a[y];

printf("***** IS IT HOT? *****\n\n");
printf("Enter No. to be input: ");
scanf("%d", &y);
if(y>10)
printf("Invalid Input!");
else
{
for(x=1;x<=y;x++)
scanf("%d", &a[x]);
printf("\n");
for(x=1;x<=y;x++)
{
if(a[x]==1)
printf("HOT!!!\n");
else if(a[x]==2)
printf("LUKE!!!\n");
else if(a[x]==3)
printf("WARM!!!\n");
else if(a[x]>=4)
printf("OUT OF RANGE!!!\n");
}}
getch();
}

Powered by Blogger.