Home » questions » C prog????????/?

C prog????????/?

2006-08-14 20:01:48, Category: Programming & Design
. Write a program that accepts any number from the keyboard and tells you whether it is a nonnegative integer. The number should be sent to the function int_test( ), which returns either the integer value, or –1 if the number is negative, or zero if it is nonnegative but not an integer. Inputs should continue until zero is input. Functions and variables main( ) input(from keyboard) integer(return from the function) int_test( ) value(from main( ) function) result(value to return) Output Your number: 48 The number is 48, Your number: -14.3 The number is negative Your number: 12.562 The number is not an integer Your number: 0

Answers

  1. steekyjim

    On 2006-08-14 20:09:01


    I'm not gonna do your coursework for you: use if statements if ($x>0) { echo = "X is positive; }
  2. india_kakinada

    On 2006-08-15 04:30:15


    #include void main() { float b,no=1; int m,n; clrscr(); no=1; while(1) { if(no!=0) { printf("\n enter ur no:"); scanf("%f",&no); if(no>0) { m=no; } else if(no<0) { m=10; } else exit(0); if(m==no) printf("\n entered no.is:%d",m); else printf("\n entered no. is:NEGITIVE"); } else exit(0); } getch(); }