Professional Documents
Culture Documents
ASSIGMENT3
ASSIGMENT3
Assignment 3
PROGRAM 1
//Write a program to check the greatest of two numbers by using the ternary
operator.
#include<stdio.h>
int main(){
int a,b;
printf("Enter two integers:\n");
scanf("%d %d", &a, &b);
a>=b?printf("The greatest number is %d.", a):printf("The greatest number is
%d.",b);
return 0;
}
OUTPUT
PROGRAM 2
//Write a program to use macro to initialize the value of Pi and calculate the area and
circumference of circle.
#include <stdio.h>
#define pi 22.0/7
int main(){
float a;
scanf("%f", &a);
return 0;
}
OUTPUT
PROGRAM 3
/*
Write a program to use the math.h header file and calculate the following:
a) Sine of an angle input by user
b)Power of the number raised to the power another number entered by user
*/
#include<stdio.h>
#include <math.h>
int main(){
float a;
scanf("%f", &a);
printf("sin(%f}=%f_\n", a, sin(a));
int b, c;
scanf("%d",&b);
scanf("%d", &c);
return 0;
}
OUTPUT
PROGRAM 4
//Write a program to illustrate the use of increment and decrement operators
#include<stdio.h>
int main(){
int a=5,b=2,c=-1,d=5;
return 0;
}
OUTPUT