Posts

Laasya looking at the friends birthday list on a social media site likes to find if the particular person's birthday year is a leap year or not. Since many will have the same doubt she decides to automate the task by writing the code snippet for finding the same but she don't know the logic to write it. Can you help Laasya to accomplish her task?

 #include <stdio.h> int main() {    int year;    scanf("%d", &year);    if (year % 400 == 0)printf("LEAP YEAR");    else if (year % 100 == 0) printf("NOT A LEAP YEAR");    else if (year % 4 == 0)printf("LEAP YEAR");    else printf("NOT A LEAP YEAR");    return 0; }

Agathiyan is the Chief In charge for carrying out World Economic Survey in India.As a part of survey his team have collected the salaries of the citizens of India. The Salaries of different people are in different number of digits.Now Agathiyan would like to classify the earnings of the citizen based on the number of digits of his/her salary into 5 different categories as follows:

#include<stdio.h> #include<stdio.h> int main() {int N; scanf("%d",&N); if(N<10) printf("Insufficient Earning"); else if (N<100) printf("Very Low Earning"); else if (N<1000) printf("Low Earning"); else if (N<10000) printf("Sufficient Earning"); else printf("High Earning"); return 0; } 

Given is an integer N.Simon chooses an integer 'a' from the positive integers not greater than 'N' with equal probability. Find the probability that 'a' is odd.

 #include <stdio.h> int main() {int n; float t; scanf ("%d",&n); if(n%2==0) printf("%d",(n/2)/n); else{     t=(n/2);     t=(t+1)/n;     printf("%.9f",t);}               return 0;}

There are two monkeys on an x-axis ready to jump in the positive direction (i.e, toward positive infinity).The first monkey starts at location x1 and moves at a rate of v1 meters per jump. The second monkey starts at location x2 and moves at a rate of v2 meters per jump. Given the starting locations and movement rates for each monkey, can you determine if they'll ever land at the same location at the same time?

 #include<stdio.h> int main() {int x1,x2,v1,v2; scanf("%d %d %d %d",&x1,&v1,&x2,&v2); int m=x1,n=x2; if (v2>v1){printf("NO");} else {for (int i=0;i<10000;i++){m=m+v1;         n=n+v2;         if(m==n){printf("YES"); break;}}     if(m!=n)printf("NO"); } return 0; }

Rohit has 'A' Chocolates and Mohit has 'B' Chocolates. Rohit will do the following action 'K' times.If Rohit has one or more Chocolates, eat one of his Chocolates.Otherwise, if Mohit has one or more Chocolates, eat one of Mohit's Chocolates.If they both have no Chocolates, do nothing.

#include<stdio.h> int main() {int A,B,K; scanf("%d %d %d",&A,&B,&K); if(A>=K) printf("%d %d",(A-K),B); else if (A<=K) printf("%d %d",0,B-(K-A)); return 0;}

Arulmozhivarman is working in ship. He is responsible for classifying the ship into different classes based on the letterclass ID of the ship.Since Arulmozhivarman is working on the same task over the long period of time he is bored of doing the same work again and again.He will enjoy his time in the ship if has a automated script that can classify the ships into different classes if the letterclass id of the ship is provided.Can you help Arulmozhivarman?

 #include <stdio.h> int main() {   char ID;     scanf("%c",&ID);     if((ID=='B')||(ID=='b'))      printf("BattleShip");     else if((ID=='C')||(ID=='c'))      printf("Cruiser");     else if((ID=='D')||(ID=='d'))      printf("Destroyer");     else      printf("Frigate"); return 0;}

Britta's parents said they will buy her a puppy on a 2nd week of a month.They selected a puppy but the vet said it will be delivered only based on the token given to them.The token was printed from 1-7 in number representing days of the week.Britta is very eager and needs to Know the Day on providing the week number [1-7].

 #include <stdio.h> int main() {     int day;     scanf("%d",&day);     if(day==1){printf("Monday");}     else if(day==2){printf("Tuesday");}      else if(day==3){printf("Wednesday");}     else if(day==4){printf("Thursday");}     else if(day==5){printf("Friday"); }     else if(day==6){printf("Saturday");}     else if(day==7){printf("Sunday");  }     else{ printf("Invalid Input");} return 0; }

Caleb and Irfan are purchasing apples which were priced according to their size.But their budget is minimum.So they plan to choose one small, one medium and one large apple so that it will fit in their budget.So can you help them choose the right apple by creating a logic by naming three apples they choose as apple1,apple2,apple3. Then check the condition if apple2 is greater than apple1 and apple3 is greater than apple2.

#include <stdio.h> int main() {     int apple1,apple2,apple3;     scanf("%d\n%d\n%d",&apple1,&apple2,&apple3);     if(apple2>apple1)     {  if(apple3>apple2)        { printf("Fit into Budget");        }else printf("Dosen't fit into Budget");     }     else     {  printf("Dosen't fit into Budget");     } return 0; }

Arav and Aaron are participating in the Bike racing. Arav have crossed some milestores earlier and Aaron crossed some milestores earlier during their racing,because they have changed their speeds at different times.Both of them like to know the difference in speeds between them at different stages of racing.Can you help finding the speed difference between Arav and Aaron?

 #include <stdio.h> int main() {     int aravspeed,aaronspeed,speeddiff;     scanf("%d%d",&aravspeed,&aaronspeed);     if(aravspeed>aaronspeed)     {  speeddiff=aravspeed-aaronspeed;        printf("%d",speeddiff);     }     else     {   speeddiff=aaronspeed-aravspeed;        printf("%d",speeddiff);     }    return 0; }

Selvan was playing with the a object of random size for stress relief. Selvan knows that the Length, Width, and Height of the object. But he would like to know the surface area of the object he is playing with. Can you help him in finding it?

 #include <stdio.h> int main() {     int length,width,height,surfacearea;     scanf("%d%d%d",&length,&width,&height);     surfacearea=2*((width*length)+(length*height)+(height*width));     printf("%d",surfacearea); return 0; }