You are on page 1of 7

Question:1

Write a program using one print statement to print the pattern of asterisks as: 
Ans:

#include<stdio.h>

void main()

Printf(“*\n**\n***\n****\n*****”);

Question:2
Write a program using one print statement to print the pattern of asterisks as 
Ans:

#include<stdio.h>

void main()

Printf(“*****\n****\n***\n**\n*”);

Question:4.  
Write a program to output the following multiplication table,
2X1=2
2X2=4
2X3=6
2X4=8
2X5=10
2X6=12
2X7=14
2X8=16
2X9=18
2X10=20
Ans:

#include<stdio.h>

void main()

{
Printf(“2X1=2\n 2X2=4\n 2X3=6\n 2X4=8\n 2X5=10\n 2X6=12\n 2X7=14\n 2X8=16\n 2X9=18\n
2X10=20 ”);

Question:5. 
Write a C program for Adding two integer numbers.
Ans:

#include<stdio.h>

void main()

Int a,b,sum;

printf(“Enter the value of a=”);

Scanf(“%d”&a);

printf(“Enter the value of b=”);

Scanf(“%d”&b);

Sum=a+b;

Printf(“Sum of the numbers:%d”,sum);

Question:6. 
Write a C program to convert temperature from Fahrenheit to Celsius and Celsius t
o Fahrenheit. 
Ans:

#include<stdio.h>

void main()

float C,F;

printf(“Enter Celcius Temperature=”);

scanf(“%f”&C);

F= ((1.8XC)+32);

printf(“The Value of Fehrenhit Temperature is : %f\n”,F);


printf(“Enter Fehrenhit Temperature=”);

scanf(“%f”&F);

C= ((F-32)*5/9);

printf(“The Value of CelciusTemperature is : %f\n”,C);

Question:7. 
Write a C program to find the total head of a flow through pipe which is at a 5m hei
ght from the 
datum line considering 5cm diameter under a pressure of 29.43 N/cm2 with a mean 
velocity of 2  m/s.
Ans:

#include<stdio.h>

void main()

float P,f,g,Hpr,v,Hv,z,Ht;

printf(“Enter the value of pressure,P=”);

scanf(“%f”,&P);

printf(“Enter the value of density,f=”);

scanf(“%f”,&f);

printf(“Enter the value of acceleration=”);

scanf(“%f”,&g);

Hpr=(p/(f*g));

printf(“The value of pressure head,Hpr=%f\n”,Hpr);

printf(“Enter the value of velocity,v=”);

scanf(“%f”,&v);

printf(“Enter the value of gravitational acceleration,g=”);

scanf(“%f”,&g);

Hv=(v*v)/(2*g);

printf(“The value of velocity head Hv=%f\n”,Hv);

printf(“Enter the value of datum head,z=”);


scanf(“%f”,&z);

Ht=Hpr+Hv+z;

Printf(“The value of total head,Ht=%f\n”,Ht);

Question:14. 
Write  a  program  to  find  out  the  area  and  perimeter  of  a  triangle  when
three vertices are given. 
Ans:

#include<stdio.h>

void main()

float X1,X2,X3,Y1,Y2,Y3,a,b,c,s,area,perimeter;

printf(“Input the value of X & Y co-ordinates,\n);

printf(“Input three numbers for X co-ordinate: (X1,X2,X3)\n=”);

scanf(“%f%f%f”,&X1,&X2,&X3);

printf(“Input three numbers for Y co-ordinate: (Y1,Y2,Y3)\n=”);

scanf(“%f%f%f”,&Y1,&Y2,&Y3);

a=sqrt((pow((X1-X2),2)+pow((Y1-Y2),2)));

b=sqrt((pow((X2-X3),2)+pow((Y2-Y3),2)));

c=sqrt((pow((X1-X3),2)+pow((Y1-Y3),2)));

s=((a+b+c)/2);

area=sqrt(s*(s-a)*(s-b)*(s-c));

printf(“Area of the triangle=%f\n”,area);

perimeter=s*2;

printf(“Perimeter of the triangle=%f\n”,perimeter);

Question:15.  
Write  a  program  to  find  out  the  area  and  perimeter  of  a  rectangle  when
four vertices are given. 
Ans:
#include<stdio.h>

void main()

float X1,X2,X3,X4,Y1,Y2,Y3,Y4,a,b,c,d,s,area,perimeter;

printf(“Input the value of X & Y co-ordinates,\n);

printf(“Input four numbers for X co-ordinate: (X1,X2,X3,X4)\n=”);

scanf(“%f%f%f%f”,&X1,&X2,&X3,&X4);

printf(“Input four numbers for Y co-ordinate: (Y1,Y2,Y3,Y4)\n=”);

scanf(“%f%f%f%f”,&Y1,&Y2,&Y3,&Y4);

a=sqrt((pow((X1-X2),2)+pow((Y1-Y2),2)));

b=sqrt((pow((X2-X3),2)+pow((Y2-Y3),2)));

c=sqrt((pow((X3-X4),2)+pow((Y3-Y4),2)));

d==sqrt((pow((X4-X1),2)+pow((Y4-Y1),2)));

area=aXb;

printf(“Area of the rectangle=%f\n”,area);

perimeter=(a+b+c+d);

printf(“Perimeter of the rectangle=%f\n”,perimeter);

Question:16.  
Write a C program to find the flow rate of a nozzle. The nozzle is situated at a dista
nce of y meter 
above the ground level and is inclined at θ degree to the horizontal.  The diameter of 
the nozzle is 
d meter and the jet of water from the nozzle strikes the ground at a horizontal dista
nce of x meter.
Ans:

#include<stdio.h>

void main()

float y,angle,y1,y2,d,a,x,g,U,q;

printf(“Input the value of angle of inclination=”);


scanf(“%f”,&angle);

y1=cos((angle*3.1416)/180);

printf(“Value of cosine of angle,y1=%f\n”,y1);

y2=tan((angle*3.1416)/180);

printf(“Value of tangent of angle,y2=%f\n”,y2);

printf(“Input the distance of nozzle above the ground,y=”);

scanf(“%f”,&y);

printf(“Input the value of horizontal distance,x=”);

scanf(“%f”,&x);

printf(“Input the value of gravitional acceleration,g=”);

scanf(“%f”,&g);

a=((3.1416/4)*d*g);

U=sqrt((g*x*x)/((2*y1*y1)*((y2*x)-y)));

Printf(“Value of the velocity,U=%f\n”,U);

Q=U*a

Printf(“Value of the flow rate of a nozzle,q=%F”,q);

Question:17.  
Write a C program to find the diameter of an equivalent pipe system that is made u
p of three 
different lengths L1, L2, L3 with corresponding three different diameters d1, d2, an
d d3.   Given that, L1+L2+L3 = L 
Ans:

#include<stdio.h>

void main()

float D1,D2,D3,L1,L2,L3,D,L;

printf(“Enter the value of : D1,D2,D3,L1,L2,L3=”);

scanf(“%f%f%f%f%f%f”,&D1,&D2,&D3,&L1,&L2,&L3);

L=L1+L2+L3;
D=pow((L/((L1/pow(D1,5))+(L2/pow(D2,5))+(L3/pow(D3,5))));

Printf(“The value of the diameter of the equivalent pipe=%f”,D);

Question:18. 
A computer manufacturing company has the following monthly compensation polic
y to their sales  persons. Write a C program to compute a sales‐
person’s gross salary.
Ans:

#include<stdio.h>

#define Base Salary 1500.00

#define Bonus Rate 200.00

#define COMMISSION 0.002

void main()

int quantity;

float gross salary,price,bonus,commission;

printf(“Input number sold and price=\n”);

scanf(“%d%f”,&quantity,&price);

bonus=Bonus Rate * quantity;

commission= COMMISSION * quantity * price;

gross salary= Base Salary+bonus+commission;

printf(“Bonus=%f\n”,bonus);

printf(“Commission=%f\n”,commission);

printf(“Gross Salary=%f\n”,gross salary);

You might also like