3
3
Flowchart
Algorithm
step 1: start
step 2: declare f,c
step 3:input f
step 4: c=(f-32)*5/9
step 5: print c
step 6: end
C program
Flowchart
Algorithm
Step 1:start
Step 2:declare real c,f
Step 3:input c
Step 4:f=(c*1.8)+32
Step 5: print f
Step 6:end
C program
#include<stdio.h>
int main()
{
float c,f;
printf("enter the value of c");
scanf("%f",&c);
f=(c*1.8)+32;
printf("%f",f);
}
Output
enter the value of c
37
98.599998
Process returned 0 (0x0) execution time : 5.148 s
Press any key to continue.
Algorithm
Step 1:start
Step2:declare integer a,r
Step 3:input r
Step 4:assign a=3.14*r*r
Step 5:print a
Step 6:end
C program
#include<stdio.h>
int main(){
int r,a;
printf("enter the value of r");
scanf("%d",&r);
a=3.14*r*r;
printf("%d",a);
}
Output
enter the value of r
45
6358
Process returned 0 (0x0) execution time : 11.053 s
Press any key to continue.
Perimeter of circle
Flowchart
Algorithm
Step 1: start
Step 2:declare integer r,p
Step 3:input r
Step 4:assign p=2*(3.14)*r
Step 5:print p
Step 6: end
C program
#include<stdio.h>
int main(){
int r,p;
printf("enter the value of r");
scanf("%d",&r);
p=2*(3.14)*r;
printf("%d",p);
}
Output
enter the value of r
21
131
Process returned 0 (0x0) execution time : 2.742 s
Press any key to continue.
Algorithm
Step 1:start
Step 2:declare integer x,y,n
Step 3:input x
Step 4:input y
Step 5: assign n=y-(x%y)
Step 7: print n
Step 8:end
C program
#include<stdio.h>
void main()
{
int x,y,n;
printf("enter the values of x,y");
scanf("%d%d",&x,&y);
n=y-(x%y);
printf("%d",n);
}
Output
enter the values of x,y
23
7
5
Process returned 1 (0x1) execution time : 3.797 s
Press any key to continue.
5.Problem statement: What is the least number must be subtracted from x to get the
number exactly divisible by y. (Find remainder x%y and remainder is the least number
must be subtracted)
Flowchart
Algorithm
Step 1:start
Step 2:declare integer x,y,r
Step 3:input x
Step 4:input y
Step 5:assign r=x%y
Step 6:print r
Step 7:end
C program
#include<stdio.h>
int main()
{
int x,y,r;
printf("enter the values of x,y");
scanf("%d%d",&x,&y);
r=x%y;
printf("%d",r);
}
Output
enter the values of x,y
22
7
1
Process returned 0 (0x0) execution time : 3.233 s
Press any key to continue.
6.Problem statement: Write a C program to calculate area and perimeter of a right angled
triangle. (Area=1/2*b*h perimeter=w+h+sqrt(w*w+h*h)
Flowchart
Algorithm
Step 1:start
Step 2:declare real a,p,b,h,w
Step 3:input b
Step 4:input h
Step 5:input w
C program
#include<stdio.h>
int main()
{
float a,p,b,h,w;
printf("enter the values of b,h,w");
scanf("%f%f%f",&b,&h,&w);
a=(0.5)*b*h;
p=w+h+sqrt((w*w)+(h*h));
printf("%f,%f",a,p);
}
Output
enter the values of b,h,w
4
4
3
8.000000,12.000000
Process returned 0 (0x0) execution time : 5.105 s
Press any key to continue.
Flowchart
Algorithm
Step 1:start
Step 2:declare integer x,y,z,n
Step 3:input x
Step 4:input y
Step 5:input z
Step 6:assign n=(x-z)/y
Step 7:print n
Step 8:end
C program
#include<stdio.h>
int main()
{
int x,y,z,n;
printf("enter the values of x,y,z");
scanf("%d%d%d",&x,&y,&z);
n=(x-z)/y;
printf("%d",n);
}
Output
enter the values of x,y,z
32
7
4
4
Process returned 0 (0x0) execution time : 8.827 s
Press any key to continue.
Convertion of cm to m
Flowchart
Algorithm
Step 1:start
Step 2:declare real c,m
Step 3:input c
Step 4:assign m=c/100
Step 5:print m
Step 6:end
C program
#include<stdio.h>
int main()
{
float c,m;
printf("enter the value of c");
scanf("%f",&c);
m=c/100;
printf("%f",m);
Output
enter the value of c
50
0.500000
Process returned 0 (0x0) execution time : 9.054 s
Press any key to continue.
Convertion of m to km
Flowchart
Algorithm
step 1:start
step 2:declare real k,m
step 3:input m
C program
#include<stdio.h>
int main()
{
float k,m;
printf("enter the value of m");
scanf("%f",&m);
k=m/1000;
printf("%f",k);
}
Output
enter the value of m
30
0.030000
Process returned 0 (0x0) execution time : 3.351 s
Press any key to continue.
12.Problem statement: Write a C program to convert the given numbers of days into
years, months and days. (Years = days/365; //Ignoring leap year ;Weeks = (days
%365)/7 ;Days = days- ((years*365) + (weeks*7)).
Flowchart
Algorithm
Step 1:start
Step 2:declare integer nd,y,w,D
Step 3:input nd
C program
#include<stdio.h>
int main()
{
int nd,y,w,D;
printf("enter the value of n,d");
scanf("%d",&nd);
y=nd/365;
w=(nd%365)/7;
D=nd-((y*365)+(w*7));
printf("%d,%d,%d",y,w,D);
}
Output
enter the value of n,d
13,29
3,33,3
Process returned 0 (0x0) execution time : 7.993 s
Flowchart
Algorithm
Step 1:start
Step 2:declare integer a,b,c
Step 3:input a
Step 4:input b
Step 5:assign c=180-(a+b)
Step 6:print c
Step 7:end
C program
#include<stdio.h>
int main()
{
int a,b,c;
printf("enter the values of a,b");
scanf("%d%d",&a,&b);
c=180-(a+b);
printf("%d",c);
}
Output
enter the values of a,b
70
60
50
Process returned 0 (0x0) execution time : 6.184 s
Press any key to continue.
Flowchart
Algorithm
Step 1:start
Step 2:declare integer a,b,c
Step 3:input a
Step 4:input b
Step 5:assign c=a-(-b)
Step 6:print c
Step 7:end
C program
#include<stdio.h>
int main()
{
int a,b,c;
printf("enter the values of a,b");
scanf("%d%d",&a,&b);
c=a-(-b);
printf("%d",c);
}
Output
enter the values of a,b
6
42
48
Process returned 0 (0x0) execution time : 5.076 s
Press any key to continue.
Algorithm
Step 1:start
Step 2:declare character c
Step 3:read c
Step 4:print ASCII of c
Step 5:end
C program
Flowchart
Algorithm
Step 1:start
Step 2:declare integer a,b,c,p,s,ar
Step 3:input a
Step 4:input b
Step 5:input c
Step 6:assign p=a+b+c
Step 7:assign s=(a+b+c)/2
Step 8:assign ar=sqrt(s*(s-a)*(s-b)*(s-c))
Step 9:print p
Step 10:print ar
Step 11:end
C program
#include<stdio.h>
int main()
{
int a,b,c,p,s,ar;
printf("enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
p=a+b+c;
s=(a+b+c)/2;
ar=sqrt(s*(s-a)*(s-b)*(s-c));
printf("%d,%d",p,ar);
}
Output
enter the values of a,b,c
3
4
5
12,6
Process returned 0 (0x0) execution time : 3.770 s
Press any key to continue.
19.Problem statement: Write a C Write a program to read the values of x, y and z and
print the results of the following expressions in one line. 1.(x+y+z) / (x-y-z) 2.
(x+y+z) / 3 3.(x+y) * (x-y) * (y-z)
Flowchart
Algorithm
Step 1:start
Step 2: declare integer x,y,z,r,a,m
step 3:input x
step 4:input y
step 5:input z
step 6:assign r=(x+y+z)/(x-y-z)
step 7:assign a=(x+y+z)/3
C program
#include<stdio.h>
int main()
{
int x,y,z,r,a,m;
printf("enter the values of x,y,z");
scanf("%d%d%d",&x,&y,&z);
r=(x+y+z)/(x-y-z);
a=(x+y+z)/3;
m=((x+y)*(x-y)*(y-z));
printf("%d,%d,%d",r,a,m);
}
Output
enter the values of x,y,z
8
3
1
3,4,110
Process returned 0 (0x0) execution time : 2.333 s
Press any key to continue.
Flowchart
Algorithm
Step 1:start
Step 2:declare real c,p,r,n
Step 3:input p
Step 4:input r
Step 5:input n
Step 6:assign c=p*((1+(r/100))^n)
Start 7:print c
Step 8:end
C program
#include<stdio.h>
int main()
{
float c,p,n,r;
printf("enter the values of p,r,n");
scanf("%f%f%f",&p,&r,&n);
c=p*(pow((1+(r/100)),n));
printf("%f",c);
}
Output
enter the values of p,r,n
1200
5.4
2
1333.099243
Process returned 0 (0x0) execution time : 12.277 s
Press any key to continue.