1.Write a program to find largest number among three number. Also, design flowchart of the program.
1.
#include <stdio.h>
#include <math.h>
//The start point of the program
int main() {
int number1;
int number2;
int number3;
int largest;
//get the first number from the user
printf("Enter the first number: ");
scanf("%d", &number1);
//get the second number from the user
printf("Enter the second number: ");
scanf("%d", &number2);
//get the third number from the user
printf("Enter the third number: ");
scanf("%d", &number3);
largest=number1;
//Find the largest number
if(number1 < number2) {
largest = number2;
}else {
largest = number1;
}
if(largest < number3) {
largest = number3;
}
// Print the largest number
printf("The largest number among three number is: %d",largest);
//delay
getchar();
getchar();
return 0;
}
flowchart
2.
#include <stdio.h>
#include <math.h>
//The start point of the program
int main() {
int number;
int exponent;
unsigned long power;
//get the number from the user
printf("Enter the number: ");
scanf("%d", &number);
printf("Enter an exponent: ");
scanf("%d", &exponent);
power=pow(number*1.0,exponent);
//display result
printf("The power of a number %d = %u",number,power);
//delay
getchar();
getchar();
return 0;
}
Comments
Leave a comment