/* 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();
}
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);
}
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).
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; }
Just use a series of ifs to check whether a < b, a > b or a == b.
please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.
1. Design an algorithm to compute sum of the squares of n numbers?
n=100 loop until n = 9 print n n = n -1 end loop
jgfujtf
ALGORITHM SAMPLE i = 0 REPEAT OUTPUT ("Enter a number: ") INPUT (number[i]) i ++ UNTIL (number[i] 0) THEN counter++ sum = sum + number[i] END IF END FOR DISPLAY (counter) DISPLAY (sum / counter) END SAMPLE
Design step by steps algorithm on how to write the letter A and display the result
please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.
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
maybe
1. Design an algorithm to compute sum of the squares of n numbers?
You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.
n=100 loop until n = 9 print n n = n -1 end loop
das
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.
jgfujtf
Start print "the sum of all even numbers is infinite" end
10001/999900