Using C Write a program that prompts the user to enter two s
Using C++ Write a program that prompts the user to enter two sides of a right triangle and then uses a function to calculate the hypotenuse. You will need to use #include , the sqrt() function, and the power function, pow(base,exponent).
Using C++ Write a program that asks a user to input their name one letter at a time, typing | after their last letter to stop entry. Store each letter into a character array, and then display their name as they would normally read it. Assume that no name will exceed 256 characters.
Solution
1)
#include <stdio.h>
#include <math.h>
int main ()
{
float a,b,c;
printf(\"enter the first side:\");
scanf (\"%f\",&a );
printf(\"enter the second side:\");
scanf (\"%f\",&b );
c= pow (a, 2)+pow(b,2);
c= sqrt(c);
printf(\"the hypotenuse is %f \ \",c);
}
you can also use commands cin and cout
2)
#include <stdio.h>
#include <math.h>
int main ()
{
char name[256];
int i=0;
char n=\'x\';//=\"x\";
printf(\"enter your name\ \");
while (n!=\'|\')
{scanf(\"%c\",&n);
name[i] = n;
i++;
}
i=0;
while (name[i]!=\'|\')
{
printf(\"%c\",name[i]);
i++;
}
}
