শুক্রবার, ১৭ এপ্রিল, ২০১৫

Age Calculation using if else if statement

Please write down a code where you can input your "age" if your age is between (0 to14) then show "You are a child" if your age is between (15 to 35) then show "You are a young" if your age is between then (36 to 50) then show "You are a middle aged" if your age is greater then 50 then show "You are a old".
Assalamolalikum dear Mentor and friends,
Now i want to share you a concept on this problem in C Programming ..
01.Firstly i have to need one variable declaration (int age;).
02.After variable declaration ,i need the code by which can i input a starting and a ending value (printf("Please Enter you Age : ");
scanf("%d", &age);)
03.Then it is necessary to me the logic implementation "(if(age>=0 && age<=14){
printf("You are a child");
}")
one by one this logic are applied .......
04.Finally show the output result ..
Here the code and Screenshot
Solution of Above problem :

//Developed By Muhammad Rakib Hasan
// Age Calculation using if else if

#include <stdio.h>
int main(){
      int age;
      printf("Please Enter you Age : ");
      scanf("%d", &age);

      if(age>=0 && age<=14){
         printf("You are a child");
      }
    else if(age>=15 && age<=35){
        printf("You are a young");
    }
    else if(age>=36 && age<=50){
        printf("You are a middle aged");
    }
    else{
        printf("You are old");
    }


      return 0;
}
Result:





কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন