Take four integer variables a, b, x and y. Scan the values of the variables from user using scanf() function. Now print the output of the following equation:
(a*b) + (x*y)
Code:
#include<stdio.h>
int main()
{
int a,b,x,y;
printf("Enter the value of a, b, x and y:\n");
scanf("%d%d%d%d",&a,&b,&x,&y);
printf("%d\n",(a*b)+(x*y));
return 0;
}
Take temperature of Dhaka city as input in Celsius scale from the user using scanf() function and convert it to Fahrenheit and print it.
[Formula: F = C(9/5) +32]
Code:
#include<stdio.h>
int main()
{
double celsius,farenheit;
printf("Enter the temperature in Celsius:");
scanf("%lf",&celsius);
farenheit=((celsius*(9.0/5.0))+32);
printf("%lf\n",farenheit);
return 0;
}
Take a small letter alphabet as input from the user and print the capital version of that letter. [If user gives input ‘a’ you should print ‘A’]
Code:
#include<stdio.h>
int main()
{
char letter;
printf("Enter a small letter: \n");
scanf("%c",&letter);
printf("Capital version is: %c\n",letter-32);
return 0;
}