Write a C program to initialize the value as 5.800000 & display the same value as 5.8.
#include <stdio.h>
int main()
{
float a=5.800000;
printf("%.1f",a);
return 0;
}
Write a C program to read N value and check that value is equal to 10 or not using if-else
#include<stdio.h>
int main()
{
int N;
scanf("%d",&N);
if(N!=10)
{
printf("Given number is NOT TEN.");
}
else
{
printf("Given number is TEN.");
}
return 0;
}
Write a C program to calculate the diameter and circumference of circle.
#include <stdio.h>
int main()
{
float a;
scanf("%f",&a);
printf("Diameter of circle=%.2f units\nCircumference of circle=%.2f units",2*a,2*3.14*a);
return 0;
}
Raju and Ramu purchased a product and they made a self analysis that if cost price and selling price of a product are input through the keyboard,Help them out to write a C program to determine whether the seller has made profit or incurred loss using IF-ELSE.
#include<stdio.h>
int main()
{
int a,b;
scanf("%d\n%d",&a,&b);
if((b-a)>0)
{
printf("Profit = %d",b-a);
}
else
{
printf("Loss = %d",a-b);
}
return 0;
}
Write a C program to check whether number is even number and divisible by 3 or not using nested if.
#include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
if(a%2==0)
{
printf("The number is even\n");
if(a%3==0)
{
printf("The number is divisible by %d",3);
}
else
{
printf("The number Not divisible by %d",3);
}
}
else
{
printf("The number is NOT an even number");
}
return 0;
}