Write a program to declare one integer variable and one float variable and
give them appropriate values using scanf(). You are required to print the two
numbers and their average. Write an output.
Answers
Answered by
6
#include <stdio.h>
int main()
{
int myInt;
float myFloat, average;
printf("Enter an integer: ");
scanf("%d", &myInt);
printf("Enter a float: ");
scanf("%f", &myFloat);
printf("myInt: %d\nmyFloat: %.2f\n", myInt, myFloat);
printf("Average: %.2f", (myInt + myFloat) / 2);
return 0;
}
Answered by
0
Answer:
#include <stdio.h>
int main()
{
int a;
float myFloat, average;
printf("Enter an integer: ");
scanf("%d", &a);
printf("Enter a float: ");
scanf("%f", &myFloat);
printf("a: %d\nmyFloat: %.2f\n",a, myFloat);
printf("Average: %.2f", (a + myFloat) / 2);
}
Explanation:
Similar questions
Social Sciences,
2 months ago
Science,
5 months ago
English,
11 months ago
Sociology,
11 months ago
Biology,
11 months ago