1. Write a C Program that read temperature in Celsius and Display in Farenheit
#include <stdio.h>int main()
{
double c,f;
printf("Enter Tempature in Celsius:");
scanf ("%lf\a",&c);
f=1.8*c+32;
printf("The Temperature in Farenheit is: %lf\a\n",f);
return 0;
}
2. Write A C Program that read two Numbers and display bitwise AND.
#include <stdio.h>int main()
{
int a,b,c;
printf("Enter Two Number=");
scanf("%d %d",&a,&b);
c=a&b;
printf("\n%d &%d=%d",a,b,c);
return 0;
}
3. Write a Program that read any angle a and Display cos(a), tan(a) ,sec(a) , cosec(a)
#include <stdio.h>#include <math.h>
int main()
{
int a;
printf("Enter Number=");
scanf("%d",&a);
printf("cos(%d)=%f\n",a,(cos(a*(3.1416)/180)));
printf("tan(%d)=%f\n",a,(tan(a*(3.1416)/180)));
printf("sec(%d)=%f\n",a,(1/(cos(a*(3.1416)/180))));
printf("cosec(%d)=%f\n",a,(1/(sin(a*(3.1416)/180))));
return 0;
}
4. Writa A C Program That generates random number between 1 to 10
#include <stdio.h>#include <stdlib.h>
int main()
{
int i,a;
printf("Enter Number=");
scanf("%d",&a);
for(i=0;i<a;i++)
{
printf("%d\n",1+rand()%10);
}
return 0;
}
5. Write A Program that Check Odd or Even using modular operator and bitwise operator
Modular Operator#include <stdio.h>
int main()
{
int a;
printf("Enter Number=");
scanf("%d",&a);
if(a%2==0)
printf("Nimber is even");
else
printf("Number is odd");
}
Bitwise Operator
#include <stdio.h>
int main()
{
int a;
printf("Enter Number=");
scanf("%d",&a);
if(a&1==1)
printf("Number Is Odd");
else
printf("Number is Even");
}
6. Write A Program that Gives Average Of 4 Numbers
#include <stdio.h>int main()
{
int a,b,c,d;
printf("Enter 4 numbers=");
scanf("%d %d %d %d",&a,&b,&c,&d);
if(a<b&&a<c&&a<d)
printf("Average is=%d",(b+c+d)/3);
else if(b<a&&b<c&&b<d)
printf("Average is=%d",(a+c+d)/3);
else if(c<a&&c<a&&c<d)
printf("Average is=%d",(a+b+d)/3);
else
printf("Average is=%d",(a+c+b)/3);
return 0;
}
7. Write A Program that Find whether a Year Is Leap Year Or Not
#include <stdio.h>int main()
{
int y;
printf("Enter year=");
scanf("%d",&y);
if(y%4==0 && (y%100!=0)||(y%400==0))
printf("%d is Leap year",y);
else
printf("%d is not leap year",y);
}
0 comments:
Post a Comment