answersLogoWhite

0


Best Answer

/* program to calculate sum of two no.s in c*/

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,sum; clrscr();

cout("enter 2 nos");

cin("%d %d ",&a,&b);

sum=a+b;

cout("sum is %d",sum);

getch();

}

User Avatar

Wiki User

βˆ™ 13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

βˆ™ 12y ago

Its easy

#include<stdio.h>

main()

{

int i,j;

printf("\n Enter any number : ");

scanf("%d", &i);

printf("\n Enter any number which is not equal to earlier : ");

scanf("%d", &j);

if (i<j)

printf("\n The smaller one is %d", i);

else

printf("\n The smaller one is %d", j);

}

Also int can be replaced with float and all the %d with %f to handle the float user input

also elseif can be added for output of equal numbers entered by user as below

#include<stdio.h>

main()

{

int i,j;

printf("\n Enter first number : ");

scanf("%d", &i);

printf("\n Enter second number : ");

scanf("%d", &j);

if (i<j)

printf("\n The smaller one is %d", i);

elseif (i==j)

printf("\n Both the numbers equal!");

else

printf("\n The smaller one is %d", j);

}

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 9y ago

The details vary from one programming language to another. In general, you can write instructions to ask the user for input. You can also write a function that doesn't ask for input, but rather accepts two parameters (in which case, ANOTHER part of the program will pressumably ask for input, then pass the information on to the function).

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 6y ago

Algorithm smallest Is:-

Input: two values, a and b

Output: smallest value of a and b

if a<b then return a else return b

In C Programming:

long double smallest (long double a, long double b) { return a<b?a:b; }

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 13y ago

Just use a series of ifs to check whether a < b, a > b or a == b.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can you write an algorithm to read two numbers then display the smallest?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Design step by steps algorithm on how to write the letter A and display the result?

Design step by steps algorithm on how to write the letter A and display the result


Write an algorithm and draw a corresponding flowchart to search a number in the given list of numbers and also display its position?

please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.


How to write an algorithm that accepts five numbers and displays the sum and average of the numbers?

1.Start Algorithm 2.Enter first number 3.Enter second number 4.Enter third number 5.Enter fourth number 6.Enter fifth number 7.Add five number 8.display five number / 2 9.Display result 10.End Algorithm


Can you write an algorithm to find the beast numbers?

maybe


Write algorithm compute sum of square of N numbers?

1. Design an algorithm to compute sum of the squares of n numbers?


Write an algorithm to check whether a number is a prime number or not?

You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.


Write an algorithm or draw a flowchart to display numbers from 100 down to 10?

n=100 loop until n = 9 print n n = n -1 end loop


Write an Assembly language program which implements sorting algorithm both ascending and descending order and display those numbers with certain delay say of 5sec between successive displays?

das


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


Write algorithm and draw flowchart to find the sum of even numbers?

jgfujtf


Write an algorithm to print sum of all even numbers?

Start print "the sum of all even numbers is infinite" end


Write an algorithm to calculate the area of a circle and display the result . Use the formulae A=ΒΆr where ΒΆ is equal to 3.1416?

10001/999900