Sum and Difference of Two Numbers in C | HackerRank Programming Solutions | HackerRank C Solutions

Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank of Programming Language C . At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight you profile to the recruiters.

In this post, you will find the solution for Sum and Difference of Two Numbers in C-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

C is one of the most widely used Programming Languages. it is basically used to build Operating System. C was developed by Dennis Ritchie in 1972. Below are some examples of C Programming which might you understanding the basics of C Programming.

Objective

The fundamental data types in c are int, float and char. Today, we’re discussing int and float data types.

The printf() function prints the given statement to the console. The syntax is printf("format string",argument_list);. In the function, if we are using an integer, character, string or float as argument, then in the format string we have to write %d (integer), %c (character), %s (string), %f (float) respectively.

The scanf() function reads the input data from the console. The syntax is scanf("format string",argument_list);. For ex: The scanf("%d",&number) statement reads integer number from the console and stores the given value in variable .

To input two integers separated by a space on a single line, the command is scanf("%d %d", &n, &m), where  and  are the two integers.

Task

Your task is to take two numbers of int data type, two numbers of float data type as input and output their sum:

  1. Declare  variables: two of type int and two of type float.
  2. Read  lines of input from stdin (according to the sequence given in the ‘Input Format’ section below) and initialize your  variables.
  3. Use the  and  operator to perform the following operations:
    • Print the sum and difference of two int variable on a new line.
    • Print the sum and difference of two float variable rounded to one decimal place on a new line.

Input Format

The first line contains two integers.
The second line contains two floating point numbers.

Constraints

  •  integer variables 
  •  float variables 

Output Format

Print the sum and difference of both integers separated by a space on the first line, and the sum and difference of both float (scaled to  decimal place) separated by a space on the second line.

Sample Input

10 4
4.0 2.0

Sample Output

14 6
6.0 2.0

Explanation

When we sum the integers  and , we get the integer . When we subtract the second number  from the first number , we get  as their difference.
When we sum the floating-point numbers  and , we get . When we subtract the second number  from the first number , we get  as their difference.

Sum and Difference of Two Numbers – Hacker Rank Solution

#include<stdio.h>

int main(){
    int i, j;
    float f, g;
    scanf("%d %d %f %f", &i, &j, &f, &g);
    printf("%d %d\n%.1f %.1f", i+j, i-j, f+g, f-g);
    return 0;
}

1,569 thoughts on “Sum and Difference of Two Numbers in C | HackerRank Programming Solutions | HackerRank C Solutions”

  1. I’ve recently started a web site, the info you offer on this website has helped me greatly. Thank you for all of your time & work. “The more sand that has escaped from the hourglass of our life, the clearer we should see through it.” by Jean Paul.

    Reply
  2. This blog is definitely rather handy since I’m at the moment creating an internet floral website – although I am only starting out therefore it’s really fairly small, nothing like this site. Can link to a few of the posts here as they are quite. Thanks much. Zoey Olsen

    Reply
  3. You can certainly see your enthusiasm within the paintings you write. The sector hopes for even more passionate writers such as you who are not afraid to mention how they believe. At all times follow your heart. “No man should marry until he has studied anatomy and dissected at least one woman.” by Honore’ de Balzac.

    Reply
  4. I’m extremely impressed with your writing talents as smartly as with the structure for your weblog. Is this a paid subject or did you modify it your self? Either way stay up the excellent quality writing, it is rare to look a great blog like this one these days..

    Reply
  5. I have not checked in here for a while as I thought it was getting boring, but the last several posts are good quality so I guess I will add you back to my everyday bloglist. You deserve it my friend 🙂

    Reply
  6. you’re truly a excellent webmaster. The web site loading speed is amazing. It seems that you are doing any distinctive trick. In addition, The contents are masterwork. you’ve performed a great process on this subject!

    Reply
  7. It’s in reality a nice and useful piece of information. I am happy that you simply shared this useful information with us. Please stay us informed like this. Thank you for sharing.

    Reply
  8. Very nice post and right to the point. I am not sure if this is actually the best place to ask but do you guys have any thoughts on where to get some professional writers? Thanks 🙂

    Reply
  9. Today, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a 30 foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views. I know this is totally off topic but I had to share it with someone!

    Reply
  10. Keep up the wonderful piece of work, I read few content on this internet site and I conceive that your site is very interesting and has got circles of great information.

    Reply
  11. It?¦s really a nice and useful piece of information. I am satisfied that you simply shared this helpful info with us. Please keep us informed like this. Thanks for sharing.

    Reply
  12. I just could not leave your website before suggesting that I actually loved the usual info an individual supply to your guests? Is gonna be back ceaselessly to check out new posts.

    Reply
  13. Established in 2013, Gate.io has grown in to a reputable trading platform. While it is not the most popular exchange, it provides users with an easy to use interface for beginners while maintaining robust and advanced charts for various skill levels – including technical traders. The exchange boasts a large number of altcoins including Dogecoin (DOGE), and is often the first exchange to add new tokens. Notably, Gate.io maintains a strong stance against any type of market manipulation. TD Ameritrade, Inc., member FINRA SIPC, a subsidiary of The Charles Schwab Corporation. TD Ameritrade is a trademark jointly owned by TD Ameritrade IP Company, Inc. and The Toronto-Dominion Bank. © 2023 Charles Schwab & Co., Inc. All rights reserved. A coin is a cryptocurrency that exists on its own blockchain. These are typically used for payments. Depending on the cryptocurrency, what those payments are used for may vary from general use in the Digital Money sub-class to a more specific use in some other sub-classes.
    http://www.xn--jj0b967am7d6nda.com/bbs/board.php?bo_table=free&wr_id=23785
    Exchanges are an essential part of the crypto ecosystem because most traditional investment firms do not offer cryptocurrencies in their portfolios. Without exchanges, you would have to find another person willing to trade crypto and agree at an exchange rate. Then, you would have to send the coins directly to each other’s cryptocurrency wallets — a somewhat convoluted process. Crypto staking would also be impossible without the service that exchanges offer. If you fail to settle your instant deposit after a day, any money left in your USD fiat wallet will be moved to your pending balance. If your current pending balance does not equal the outstanding balance, Crypto will liquidate your crypto assets. In addition to selling your crypto to fiat currency on a credit debit card, you can also choose to sell and withdraw your crypto to bank accounts. Find out which suits you best as we outline the differences between the two features.

    Reply
  14. where can i get generic mobic price [url=https://mobic.store/#]cheap mobic without rx[/url] buy generic mobic no prescription

    Reply
  15. Hey would you mind letting me know which hosting company you’re using? I’ve loaded your blog in 3 different internet browsers and I must say this blog loads a lot faster then most. Can you suggest a good web hosting provider at a fair price? Thanks a lot, I appreciate it!

    Reply
  16. My partner and I absolutely love your blog and find nearly all of your post’s to be just what I’m looking for. Does one offer guest writers to write content for yourself? I wouldn’t mind creating a post or elaborating on a lot of the subjects you write in relation to here. Again, awesome web log!

    Reply
  17. Hiya, I am really glad I’ve found this information. Nowadays bloggers publish just about gossips and internet and this is actually annoying. A good web site with interesting content, that is what I need. Thank you for keeping this web-site, I’ll be visiting it. Do you do newsletters? Can not find it.

    Reply
  18. п»їlegitimate online pharmacies india [url=http://indiapharmacy.cheap/#]online pharmacy india[/url] indianpharmacy com

    Reply
  19. reputable mexican pharmacies online [url=https://mexicanpharmacy.guru/#]best online pharmacies in mexico[/url] mexico pharmacies prescription drugs

    Reply
  20. I don’t know whether it’s just me or if perhaps everybody else encountering issues with
    your site. It seems like some of the text on your
    content are running off the screen. Can somebody else please provide feedback and let me know if this is happening to
    them too? This might be a issue with my web browser because I’ve
    had this happen before. Kudos

    Reply
  21. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.

    You definitely know what youre talking about, why waste your intelligence on just posting videos
    to your weblog when you could be giving us something enlightening to read?

    Reply
  22. doxycycline online canada without prescription [url=https://doxycyclineotc.store/#]buy doxycycline over the counter[/url] cost of doxycycline in india

    Reply
  23. Generic Cialis without a doctor prescription [url=https://cialis.foundation/#]cialis for sale[/url] Generic Tadalafil 20mg price

    Reply
  24. Attractive section of content. I just stumbled upon your site and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Anyway I will be subscribing to your augment and even I achievement you access consistently fast.

    Reply
  25. Hey there would you mind sharing which blog platform you’re working with? I’m planning to start my own blog in the near future but I’m having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something unique. P.S My apologies for being off-topic but I had to ask!

    Reply
  26. No two clients are exactly alike. Some clients may want to chat frequently in person, while others may like to communicate only through text. Some may want to know every detail and decision while others are more hands-off. Leading agents realize this and never use a cookie-cutter approach when engaging with their clients and other agents. They know that communication skills top the list of qualities of a good real estate agent and strive to excel in the following four areas: A listing agent needs to know how to create a strong first impression online because most people shop for homes virtually before they ever visit a property for sale. The photos, videos and descriptive writing need to stand out in the listing, which will get posted on multiple sites, such as the brokerage’s website and consumer-focused sites like Zillow or Redfin. As a buyer, you’ll want an agent who can find newly listed homes at least as quickly as you can, if not faster—and has the resources to find homes for sale that aren’t listed on traditional channels.
    https://legit-directory.com/listings12603056/what-is-the-salary-of-a-construction-inspector
    Service provided to parents to establish legal paternity of child. For eligibility information, please contact the Franklin County Health Department. The Tennessee Real Estate Commission (TREC) has a few requirements to become a real estate agent. You must be at least 18 years old, have a high school diploma (or equivalent), and pass a background check. If you meet the prerequisites, you can complete the following steps: You will need to complete 60 hours of coursework in the areas of real estate principles and fundamentals. In addition, prior to your license being issued, you will need to satisfactorily complete a 30-hour Course for New Affiliates. While many newly licensed agents are looking for the best commission splits when shopping for brokers, we would highly recommend that you make that #2 or #3 on your list. The most important thing you should look for in a brokerage is how they support brand new real estate agents. Do they have a formal training program? Will you have at least 3 people you can reach out to if you have questions? Are they available outside traditional business hours? Do they have mentors – and what exactly will the mentors do to assist you? All important things to consider when you are ready to become a real estate agent in Tennessee!

    Reply
  27. This design is steller! You obviously know how to keep a reader amused.

    Between your wit and your videos, I was almost moved to
    start my own blog (well, almost…HaHa!) Wonderful job.
    I really enjoyed what you had to say, and more than that,
    how you presented it. Too cool!

    Reply
  28. Sight Care is a daily supplement proven in clinical trials and conclusive science to improve vision by nourishing the body from within. The Sight Care formula claims to reverse issues in eyesight, and every ingredient is completely natural.

    Reply
  29. You actually make it seem so easy with your presentation but I find this matter to be really something that I think I would never understand. It seems too complex and very broad for me. I’m looking forward for your next post, I’ll try to get the hang of it!

    Reply
  30. Cortexi is a completely natural product that promotes healthy hearing, improves memory, and sharpens mental clarity. Cortexi hearing support formula is a combination of high-quality natural components that work together to offer you with a variety of health advantages, particularly for persons in their middle and late years. Cortex not only improves hearing but also decreases inflammation, eliminates brain fog, and gives natural memory protection.

    Reply
  31. Boostaro increases blood flow to the reproductive organs, leading to stronger and more vibrant erections. It provides a powerful boost that can make you feel like you’ve unlocked the secret to firm erections

    Reply
  32. Puravive introduced an innovative approach to weight loss and management that set it apart from other supplements. It enhances the production and storage of brown fat in the body, a stark contrast to the unhealthy white fat that contributes to obesity.

    Reply
  33. FitSpresso stands out as a remarkable dietary supplement designed to facilitate effective weight loss. Its unique blend incorporates a selection of natural elements including green tea extract, milk thistle, and other components with presumed weight loss benefits.

    Reply
  34. Neotonics is an essential probiotic supplement that works to support the microbiome in the gut and also works as an anti-aging formula. The formula targets the cause of the aging of the skin.

    Reply
  35. EyeFortin is a natural vision support formula crafted with a blend of plant-based compounds and essential minerals. It aims to enhance vision clarity, focus, and moisture balance.

    Reply
  36. The Quietum Plus supplement promotes healthy ears, enables clearer hearing, and combats tinnitus by utilizing only the purest natural ingredients. Supplements are widely used for various reasons, including boosting energy, lowering blood pressure, and boosting metabolism.

    Reply
  37. SonoVive™ is an all-natural supplement made to address the root cause of tinnitus and other inflammatory effects on the brain and promises to reduce tinnitus, improve hearing, and provide peace of mind.

    Reply
  38. GlucoBerry is one of the biggest all-natural dietary and biggest scientific breakthrough formulas ever in the health industry today. This is all because of its amazing high-quality cutting-edge formula that helps treat high blood sugar levels very naturally and effectively.

    Reply
  39. Amiclear is a dietary supplement designed to support healthy blood sugar levels and assist with glucose metabolism. It contains eight proprietary blends of ingredients that have been clinically proven to be effective.

    Reply
  40. Cortexi is an effective hearing health support formula that has gained positive user feedback for its ability to improve hearing ability and memory. This supplement contains natural ingredients and has undergone evaluation to ensure its efficacy and safety. Manufactured in an FDA-registered and GMP-certified facility, Cortexi promotes healthy hearing, enhances mental acuity, and sharpens memory.

    Reply
  41. Kerassentials are natural skin care products with ingredients such as vitamins and plants that help support good health and prevent the appearance of aging skin. They’re also 100% natural and safe to use. The manufacturer states that the product has no negative side effects and is safe to take on a daily basis. Kerassentials is a convenient, easy-to-use formula.

    Reply
  42. Sight Care is a daily supplement proven in clinical trials and conclusive science to improve vision by nourishing the body from within. The Sight Care formula claims to reverse issues in eyesight, and every ingredient is completely natural.

    Reply
  43. Thoroughly enjoyed your article! The insights are valuable, and I’m curious if you plan to add more images in your upcoming pieces. It could make the content even more captivating for readers.

    Reply
  44. EndoPump is a dietary supplement for men’s health. This supplement is said to improve the strength and stamina required by your body to perform various physical tasks. Because the supplement addresses issues associated with aging, it also provides support for a variety of other age-related issues that may affect the body. https://endopumpbuynow.us/

    Reply
  45. Claritox Pro™ is a natural dietary supplement that is formulated to support brain health and promote a healthy balance system to prevent dizziness, risk injuries, and disability. This formulation is made using naturally sourced and effective ingredients that are mixed in the right way and in the right amounts to deliver effective results. https://claritoxprobuynow.us/

    Reply
  46. Glucofort Blood Sugar Support is an all-natural dietary formula that works to support healthy blood sugar levels. It also supports glucose metabolism. According to the manufacturer, this supplement can help users keep their blood sugar levels healthy and within a normal range with herbs, vitamins, plant extracts, and other natural ingredients. https://glucofortbuynow.us/

    Reply
  47. Unlock the incredible potential of Puravive! Supercharge your metabolism and incinerate calories like never before with our unique fusion of 8 exotic components. Bid farewell to those stubborn pounds and welcome a reinvigorated metabolism and boundless vitality. Grab your bottle today and seize this golden opportunity! https://puravivebuynow.us/

    Reply
  48. Решил признаться в чувствах и подарил ей прекрасный букет от “Цветов.ру”. Эти цветы стали моими немыми словами любви. Рекомендую всем, кто хочет сделать важное признание – выбирайте “Цветов.ру” для ваших эмоциональных шедевров. Советую! Вот ссылка https://%D0%B0%D0%B2%D0%B8%D1%82%D0%BE-%D0%BC%D0%BE%D1%81%D0%BA%D0%B2%D0%B0.%D1%80%D1%84/kaluga/ – букет

    Reply
  49. Hola! I’ve been reading your website for a long time now and finally got the bravery to go ahead and give you a shout out from Huffman Tx! Just wanted to tell you keep up the excellent work!

    Reply
  50. Island Post is the website for a chain of six weekly newspapers that serve the North Shore of Nassau County, Long Island published by Alb Media. The newspapers are comprised of the Great Neck News, Manhasset Times, Roslyn Times, Port Washington Times, New Hyde Park Herald Courier and the Williston Times. Their coverage includes village governments, the towns of Hempstead and North Hempstead, schools, business, entertainment and lifestyle. https://islandpost.us/

    Reply
  51. Laser eye surgery, also known as refractive or laser surgery, is a popular medical procedure in India that aims to correct common vision problems such as nearsightedness (myopia), farsightedness (hyperopia), and astigmatism. The most common types of laser eye surgery performed in India include LASIK (Laser-Assisted In Situ Keratomileusis) and PRK (Photorefractive Keratectomy).

    Reply