Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:47:07+00:00 2026-05-24T19:47:07+00:00

/* Write macro for the following : 1. Arithmetic Mean of two no. 2.

  • 0
/* Write macro for the following : 

1. Arithmetic Mean of two no.
2. Absolute value of a no.
3. To convert a Uppercase letter to lower case.
4. To obtain bigger of two numbers.

*/

#include<stdio.h>

#define am(a,b) ((a+b)/2)
#define abs(a) (a>=0?a:-a)
#define ul(ch) (ch>=65 && ch<=96 ? ch+32 : ch)
#define bigger(a,b) (a>=b?a:b)

int main () {

    int x,y;
    char c;

    printf("\nEnter two numbers:");
            scanf("%d%d",&x,&y);

    printf("\nThe arithmetic mean of two numbers is %f",(float)am(x,y));

    printf("\nEnter the number:");
            scanf("%d",&x);

    printf("\nThe absolute value of the number is %d",abs(x));

    printf("\nEnter the character:");
            scanf("%c",&c);

    printf("\nThe letter in lower case  is %c",ul(c));

    printf("\nEnter two numbers:");
            scanf("%d%d",&x,&y);

    printf("\nThe bigger of two numbers is %d",bigger(x,y));


 return 0;

 }

Everything is working fine except that program does not stop for taking character input.

Here is the snapshot of the output ….

  Enter two numbers:4
  5
  The arithmetic mean of two numbers is 4.000000

  Enter the number:-7   **/*After hitting enter here it reaches line no. 7 */** 
  The absolute value of the number is 7

  Enter the character:                                          
  The letter in lower case  is  

  Enter two numbers:4   **/*line no. 7*/**
  6

  The bigger of two numbers is 6
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:47:08+00:00Added an answer on May 24, 2026 at 7:47 pm

    I believe the problem here is that your scanf(“%c”,&c) is grabbing the carriage return entered when you hit enter to put in the -7.

    Put a getchar (or another scanf(“%c”,&c)) right before the scanf and you shouldn’t have that problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone can explain in details what the following macro does? #define write_XDATA(address,value) (((char *)0x010000)
Is it possible to write a macro that has a type and a value
I want to write a macro that compares two times that is available in
I try to write a macro in clojure that sets up a namespace and
I would like to write a macro for Notepad++ which should replace char1, char2,
I am trying to write a macro for Building my application, kicking off an
I'm trying to write a macro to make a specific usage of callbacks in
I'm trying to write a macro that toggles between release/debug solution configurations in Visual
Let's say that for some reason you need to write a macro: MACRO(X,Y) .
I'm trying to write a vba macro for a group tha has one workbook

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.