Professional Documents
Culture Documents
Assignment 5
Assignment 5
and then displays the two right–most digits of the integral part of
the number. (Example: Number is 172.35 then output is 72).
Program
#include <stdio.h>
int main()
float a;
int p,c;
scanf("%f",&a);
p=a;
c=p%100;
printf("%d",c);
return 0;
}
OUTPUT
Program
#include<stdio.h>
int main()
int m,n;
printf("Enter m= ");
scanf("%d",&m);
printf("Enter n= ");
scanf("%d",&n);
return 0;
OUTPUT
Program
#include <stdio.h>
int main()
{
int x=5,y=2;
float z;
z=(float)x/y;
printf("%f",z);
return 0;
OUTPUT
Program
#include <stdio.h>
#include<ctype.h>
int main()
char x=getchar();
isalpha(x)?(islower(x)?putchar(toupper(x)):putchar(tolower(x))):pri
ntf("non alphabet");
return 0;
OUTPUT
Program 5: Print multiplication (3 digit numbers ) and division
operation (numerator 4 digits and denominator 2 digits) using
traditional methods. You have to print all steps of operation.
Program
#include <stdio.h>
int main()
int n1,n2,n3,a,b,c;
printf("n1=");
scanf("%d",&n1);
printf("n2=");
scanf("%d",&n2);
n3=n1*n2;
a=n2/100;
b=(n2/10)%10;
c=n2%10;
printf(" %d\n",n1);
printf(" *%d\n",n2);
printf("______\n");
printf(" %d\n",n1*c);
printf(" %d*\n",n1*b);
printf("%d**\n",n1*a);
printf("______\n");
printf("%d\n",n3);
printf("______\n");
return 0;
OUTPUT
Program 5: Print multiplication (3 digit numbers ) and division
operation (numerator 4 digits and denominator 2 digits) using
traditional methods. You have to print all steps of operation.
#include <stdio.h>
int main()
int n1,n2,n3,p,a,b,c,d,e,f;
scanf("%d%d",&n1,&n2);
d=(n1/100);
e=(n1/10)%10;
f=n1%10;
n3=n1/n2;
a=(n3/100);
b=(n3/10)%10;
c=n3%10;
printf(" ____\n");
printf("%d/%d |%d\n",n2,n1,n3);
printf(" -%d\n",n2*a);
printf(" _____\n");
printf(" %d%d\n",d-n2*a,e);
printf(" %d\n",n2*b);
printf(" _____\n");
printf(" %d%d\n",(d-n2*a)*10+e-(n2*b),f);
printf(" %d\n",n2*c);
printf(" _____\n");
printf(" %d\n",n1%n3);
printf(" _____\n");
return 0;
}
OUTPUT
Program 6: Area of a triangle is given by the formula
Program
#include <stdio.h>
#include <math.h>
int main()
float a,b,c,s,d,Area;
scanf("%f%f%f",&a,&b,&c);
printf("a=%fb=%fc=%f\n",a,b,c);
s=(a+b+c)*1/2;
d=s*(s-a)*(s-b)*(s-c);
Area=pow(d,0.5);
return 0;
OUTPUT
Program 7: Write a program to check whether a given number is greater than 100 and
less than 200 that are divisible by 7 and if yes, then print the sum of digits of
the number
Program.
#include <stdio.h>
int main()
{
int n,a,b,c;
scanf("%d",&n);
printf("n=%d\n",n);
a=(n/100);
b=(n/10)%10;
c=n%10;
if(n>=100&&n<=200&&n%7==0)
else
printf("Not");
return 0;
}
OUTPUT
Program 8: If the three sides of a triangle are entered through the keyboard, write a program to check
whether the triangle is isosceles, equilateral, or right angled triangle.
Program
#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a==b&&b==c)
printf("Equilateral triangle");
else if(a==b&&c!=b||c==b&&a!=b||a==c&&a!=b)
printf("isosceles");
else if(a*a+b*b==c*c||c*c+b*b==a*a||a*a+c*c==b*b)
else
printf("triangle");
}
return 0;
OUTPUT