C Program to Accept a Page number and Display the chapter number

A book has 20 chapters and every chapter has 30 pages each, write a program to accept a page number and display the chapter number.

Input 45
Output 2

Input 90
Output 3

Input 600
Output 20

Input 610
Output -1



int main(){

    float z,a,n;


    if(n<=30) printf("%.f",floor(z));
    else if (n>600)     printf("-1");
    else printf("%.f",ceil(z));

    return 0;
Code language: C/AL (cal)

Leave a Comment