Problem: C program for "In a town, the percentage of men is 52. The percentage of total literacy is 48. if total percentage of literate men is 35 of total population, write a program to find the total number of illiterate men and women if the population of the town is 80000."
Logic used :
- Calculate total population of men using given data and store it in a variable
- Calculate total population of literate men using given data and store it in another variable
- Calculate population of illiterate men by subtracting upper two variables and store it in another variable
- Calculate total literacy using given data and store it in a variable
- Calculate total literate women by subtracting total literate men by total literacy
- Calculate total illiterate women by adding total men to literate women and then subtract the result by total population
Demo :
m = p*52/100;
lm = p*35/100;
ilm = m-lm;
tl=p*48/100;
lw = tl-lm;
ilw = p-(m+lw);
C program :
// Program by Shyam Kanth#include<stdio.h>int main(){int p =80000, m,lm,ilm,tl,lw,ilw;m = p*52/100;lm = p*35/100;ilm = m-lm;tl=p*48/100;lw = tl-lm;ilw = p-(m+lw);printf("Total number of illetrate men is %d.\n",ilm);printf("Total number of illetrate women is %d.\n",ilw);return 0;}
- #include < stdio.h > : Header file for input output
- int : Integer data type
- p, m, lm, ilm, tl,lw, ilw : Variable used
- printf : Function for displaying message
- scanf : Function for taking input
Do comments, if any doubt
Know about me : Shyam Kanth
No comments:
Post a Comment