Assignment-1
Assignment-1
INPUT
#include <stdio.h>
int main()
{
printf("Hello");
}
OUTPUT
/tmp/UO2khoY82r.o
Hello
2. INPUT
#include <stdio.h>
int main()
{
printf("Write a program to print a Sentence.");
}
OUTPUT
/tmp/371fuvvJfm.o
Write a program to print a Sentence.
3. INPUT
#include <stdio.h>
int main()
{
int n;
printf("enter the integer number-");
scanf("%d",&n);
printf("you have entered:%d",n);
}
OUTPUT:
/tmp/IRaUGBY3wy.o
enter the integer number-45
you have entered:45
4.INPUT
#include <stdio.h>
int main()
{
int n,n1;
printf("enter two numbers-");
scanf("%d%d",&n,&n1);
printf("\naddition=%d",n+n1);
}
OUTPUT
/tmp/izXucbZpkV.o
enter two numbers-5 87
addition=92
5.INPUT
#include <stdio.h>
int main()
{
float n,n1;
printf("enter two numbers-");
scanf("%f%f",&n,&n1);
printf("\nmultiplication=%f",n*n1);
}
OUTPUT
/tmp/lW081k5Ala.o
enter two numbers-7 5
multiplication=35.000000
6.INPUT
#include <stdio.h>
int main()
{
float r,area,circumference;
printf("enter the radius-");
scanf("%f",&r);
area=3.14*r*r;
circumference=2*3.14*r;
printf("\narea of the circle is=%f",area);
printf("\circumference of the circle is=%f",circumference);
}
OUTPUT
/tmp/Tjp4jIQw7r.o
enter the radius-5
7. INPUT
#include <stdio.h>
int main()
{
int side,length,height,sq,rect;
printf("enter the side of square-");
printf("\nenter the length of rectangle-");
printf("\nenter the height of rectangle-");
scanf("%d%d%d",&side,&length,&height);
sq=side*side;
rect=length*height;
printf("\n the area of square is= %d",sq);
printf("\n the area of rectangle is= %d",rect);
}
8.INPUT
#include <stdio.h>
void main()
{
float p=4,r=5,t=7,SI;
SI=(p*t*r)/100;
printf("simple interest=%f\n",SI);
}
OUTPUT
/tmp/miCBDrNAgx.o
simple interest=1.400000
11.INPUT
#include <stdio.h>
void main()
{
float f,c;
printf("enter the temperature in Fahrenheit:");
scanf("%f",&c);
f=((c-32)*5/9);
printf("celsius:%2.f",f);
}
OUTPUT
/tmp/T0aj9sn2oQ.o
enter the temperature in Fahrenheit:52.23
celsius:11
12. INPUT
#include <stdio.h>
void main()
{
float f,c;
printf("enter the temperature in celsius:");
scanf("%f",&f);
c=((f-32)*5/9);
printf("fehrenheit:%2.f",c);
}
OUTPUT
/tmp/2UJYBdyYzI.o
enter the temperature in celsius:46.58
fehrenheit: 8
13. INPUT
#include <stdio.h>
void main()
{
float a,b,c,d,e;
float total,p;
printf("enter marks of five subjects-");
scanf("%f%f%f%f%f",&a,&b,&c,&d,&e);
total=a+b+c+d+e;
p=(total/500)*100;
printf("total marks=%.2f\n",total);
printf("percentage=%.2f",p);
}
OUTPUT
/tmp/ZTbhLJmQPA.o
enter marks of five subjects-58 78 88 52 23
total marks=299.00
percentage=59.80
14. INPUT
#include <stdio.h>
void main()
{
printf("GLS insititue of Computer Applications");
}
OUTPUT
/tmp/cMcyafmQUF.o
GLS insititue of Computer Applications
15. INPUT
#include <stdio.h>
void main()
{
float n1,n2,n3,sum;
printf("Enter three number-");
scanf("%f%f%f",&n1,&n2,&n3);
sum=n1+n2+n3;
printf("the addition is %f-",sum);
}
OUTPUT
/tmp/oLDnhow3uj.o
Enter three number-5 12 8
the addition is 25.000000-
16. INPUT
#include <stdio.h>
void main()
{
float n1,n2,subtraction;
printf("Enter two number-");
scanf("%f%f",&n1,&n2);
subtraction=n1-n2;
printf("the subtraction is %f-",subtraction);
}
OUTPUT
/tmp/eMITfVofbB.o
Enter two number-4 5
the subtraction is -1.000000-
17. INPUT
#include <stdio.h>
void main()
{
float n1,n2,n3,div;
printf("Enter three number-");
scanf("%f%f%f",&n1,&n2,&n3);
div=n1/n2/n3;
printf("the divison is %f-",div);
}
OUTPUT
/tmp/sGuk6cz7mR.o
Enter three number-5 10 15
the divison is 0.033333-
18. INPUT
#include <stdio.h>
void main()
{
float n1,n2,multiplication;
printf("Enter two number-");
scanf("%f%f",&n1,&n2);
multiplication=n1*n2;
printf("the multiplication is %f-",multiplication);
}
OUTPUT
/tmp/QpNR5PUV5d.o
Enter two number-2 5
the multiplication is 10.000000-
19. INPUT
#include <stdio.h>
void main()
{
int a,b,p;
printf("Enter length and breath of rectangle-");
scanf("%d%d",&a,&b);
p=a+b;
printf("perimeter of rectangle is %d",p);
}
OUTPUT
/tmp/0oKp5dUSjg.o
Enter length and breath of rectangle-8 3
perimeter of rectangle is 11
20.INPUT
#include <stdio.h>
void main()
{
int a,b,t;
printf("Enter height and base of triangle-");
scanf("%d%d",&a,&b);
t=a*b/2;
printf("area of triangle is %d",t);
}
OUTPUT
/tmp/LMipyOiK8S.o
Enter height and base of triangle-5 2
area of triangle is 5
=== Code Exited With Errors ===
21.INPUT
#include <stdio.h>
void main()
{
int a,b,c,d,e,avg;
printf("Enter five numbers-");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
avg=(a+b+c+d+e)/5;
printf("Average is %d",avg);
}
OUTPUT
/tmp/lKbbe53wV6.o
Enter five numbers-8 5 6 2 3
Average is 4
22.INPUT
#include <stdio.h>
void main()
{
int a,b,c,d,e,x;
printf("Enter five numbers-");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
x=(a+b*c)/d+e;
printf("the value of x %d",x);
}
OUTPUT
/tmp/r7cjamITfX.o
Enter five numbers-7 8 5 1 4
the value of x 51
23. INPUT
#include <stdio.h>
void main()
{
float r,h,v;
printf("Enter radius and height of cylinder-");
scanf("%f%f",&r,&h);
v=3.14*r*2*h;
printf("the area of cylinder is %.2f",v);
}
OUTPUT
/tmp/9cQfaaJdwJ.o
Enter radius and height of cylinder-2 3
the area of cylinder is 37.68
OUTPUT
/tmp/KcRAhCV3n0.o
Enter radius of circle-5
the circumference of circle is 31
25. INPUT
#include <stdio.h>
void main()
{
char c;
printf("enter a character:");
scanf("%c",&c);
printf("\nyou entered %c",c);
printf("\nASCII value of %c = %d",c,c);
}
OUTPUT
/tmp/f1bQ6pkUq9.o
enter a character:E
you entered E
ASCII value of E = 69
26. INPUT
#include <stdio.h>
void main()
{
int n;
printf("enter a number:");
scanf("%d",&n);
printf("\nyou entered %d",n);
printf("\nASCII value of %d = %c",n,n);
OUTPUT
/tmp/Cw6LQeqNxZ.o
enter a number:89
you entered 89
ASCII value of 89 = Y