How to write a program that asks the users to enter two integers, obtains the numbers from user, then prints the larger number followed by the words "is larger", if the numbers are equal, print the message "these are equal". use only the single-selection form of the if statement.

Recommended Answers

All 10 Replies

it can be done by using "if"conditional statemnts

ya here is the desired programme

#include<stdio.h>
main()
{
int a,b;
printf("enter the values to be compared");
scanf("%d %d",&a,&b);
if(a>b)
printf("%d is larger than %d",a,b);
else
printf("%d is smaller than %d",a,b);
}

I would start with the basics.. do you know how to actually have the program take input from the user?

hi kamatari .wht is ur problem ?

I don't have one, the opening poster does. On my first read I didn't really understand the way the question was presented and assumed this was a first project; I asked if the person knew the basics. Did you get offended or something?

To be honest it looked like this question was just copied from where ever it came from without the user trying to do it.

Describe your problem clearly and fully!

So you have a great title and you're ready to compose a post. Resist the temptation to copy and paste your code and as an afterthought say "It doesn't work". That's not a description of the problem. If you want help, you have to give us enough information to work with. Include at least all of the following in your description of the problem:

1) An overview of what your program does.
2) The result of your current code.
3) What you expected your code to do.
4) The contents of any input files (if appropriate)

This tells us what context your program is in so that we can offer alternative solutions. It tells us exactly what your code does so that we can more easily pinpoint the problem without performing tedious troubleshooting steps. Finally, it tells us what you wanted your code to do so that we can compare what it does with what you wanted it to do. Most of the time, a knowledgeable member can answer your question almost immediately using just this information.

Don't give away code!

You might feel inclined to help someone else. That's great! But don't solve the problem for them. Our goal is to help people to learn, and giving away answers doesn't achieve that goal. Naturally giving away the answer is a subjective thing, so just make sure that the person you help can't just take your code and turn it in for a grade. We want the people we help to do enough work to learn something meaningful.

I do not have a problem.

commented: keep it up!! +1

thanks a lot cindrilla! :)
but now i got new problem,
how can i write a program that asks the user input Name, Age, Date Of Birth, Place Of Birth, and Email Address?
i tried several times to write the program but only "Name" input succeeded. can you help me?

Post your code that you have tried and not working.. and please start new thread for new problem.. after your problem get solved mark your thread as solved..

It really is the same as your first problem. You use integers for age,and date of birth ; and strings, or characters with loops for place of birth and email address.

:)

thanks kamatari for the feedback :)
and yes, for your information,
i'm just learning programming for a month and I still can't fully understand the basics of programming.
when I got the first assignment from lecturer, I was a little bit nervous and worried if I was not able to complete the task.
and please don't get me wrong, my sincere intent to learn and not to take a chance on good people who helped me solve the problem.
haha:D what a bad english.
btw, thanks once again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.