Friday 12 May 2023

Questions

 Exercise 1

Set A . Apply all the three program development steps for the following examples.

 1. Accept dimensions of a cylinder and print the surface area and volume (Hint: surface area =
2pr2 + 2prh, volume = pr2h)


2. Accept temperatures in Fahrenheit (F) and print it in Celsius(C) and Kelvin (K) (Hint: C=5/9(F-
32), K = C + 273.15)

 3. Accept initial velocity (u), acceleration (a) and time (t). Print the final velocity (v) and the
distance (s) travelled. (Hint: v = u + at, s = u + at2)

 4. Accept inner and outer radius of a ring and print the perimeter and area of the ring (Hint:
perimeter = 2 p (a+b) , area = p (a2-b2) )

 5. Accept two numbers and print arithmetic and harmonic mean of the two numbers (Hint: AM=
(a+b)/2 , HM = ab/(a+b) )

 6. Accept three dimensions length (l), breadth(b) and height(h) of a cuboid and print surface
area and volume (Hint : surface area=2(lb+lh+bh ), volume = lbh )

 7. Accept a character from the keyboard and display its previous and next character in order.
Ex. If the character entered is ‘d’, display “The previous character is c”, “The next character is e”.

 8. Accept a character from the user and display its ASCII value.

Saturday 29 April 2023

Exercise 1-To demonstrate the use of data types, simple operators and expressions - 1


SET A

1. Accept dimensions of a cylinder and print the surface area and volume (Hint: surface area =
2pr2 + 2prh, volume = pr2h)

#include<stdio.h>
#include<conio.h>

void main()
{
 float r,h,sa,v;
 clrscr();

 printf("\nFinding Surface Area of cylinder and volume:");
 printf("\nEnter the radius of cylinder in cm:");
 scanf("%f",&r);
 printf("\nEnter the height of cylinder in cm:");
 scanf("%f",&h);

 sa=(2*3.14*r*r)+(2*3.14*r*h);
 printf("\nSurface area of cylinder:%f",sa);

 v=3.14*r*r*h;
 printf("\nvolum of Cylinder:%f",v);

 getch();
} 
/*
output:

Finding Surface Area of cylinder and volume:                                   
Enter the radius of cylinder in cm:3                                           
                                                                               
Enter the height of cylinder in cm:3                                           

Surface area of cylinder:113.040001
volum of Cylinder       :84.779999
*/ 


Exercise 1-To demonstrate the use of data types, simple operators and expressions - 7

 7. Accept a character from the keyboard and display its previous and next character in order.

Ex. If the character entered is ‘d’, display “The previous character is c”, “The next character is e”.
 

#include<stdio.h>
#include<conio.h>

void main()
{
 char m;

 clrscr();

 printf("\nFinding the first and last charcher of enter character on basis on ABC..");
 printf("\nEnter the characher:");
 scanf("%c",&m);
 printf("\nFirst character is:%c",m+1);
 printf("\nLast character is:%c",m-1);



 getch();
}

/*

Finding the first and last charcher of enter character on basis on ABC..       
Enter the characher:T                                                          
                                                                               
First character is:U                                                           
Last character is:S                                                            
 */

Exercise 1-To demonstrate the use of data types, simple operators and expressions - 6

 6. Accept three dimensions length (l), breadth(b) and height(h) of a cuboid and print surface

area and volume (Hint : surface area=2(lb+lh+bh ), volume = lbh )
 

#include<stdio.h>
#include<conio.h>

void main()
{
 int l,b,h;
 float sa,v;
 clrscr();

 printf("\nFinding the surfacearea and volume of cubiod:");
 printf("\nEnter the lenght of cubiod:");
 scanf("%d",&l);
 printf("\nenter the  breath of cubiod:");
 scanf("%d",&b);
 printf("\nEnter the height of cubiod:");
 scanf("%d",&h);

 sa=2*(l*b+l*h+b*h);
 printf("\nSurface area of cubiod is:%f",sa);

 v=l*b*h;
 printf("\nVolume of cubiod is:%f",v);

 getch();
}

/*

Finding the surfacearea and volume of cubiod:                                  
Enter the lenght of cubiod:5                                                   
                                                                               
enter the  breath of cubiod:4                                                  
                                                                               
Enter the height of cubiod:6                                                   
                                                                               
Surface area of cubiod is:148.000000                                           
Volume of cubiod is:120.000000                                                 
*/
 

Exercise 1-To demonstrate the use of data types, simple operators and expressions - 4

 4. Accept inner and outer radius of a ring and print the perimeter and area of the ring (Hint:

perimeter = 2 p (a+b) , area = p (a2-b2) )

#include<stdio.h>
#include<conio.h>

void main()
{
 int ir,or;
 float peri,area;
 clrscr();

 printf("\nFinding the perimeter and area of ring:");
 printf("\nEnter the inner radius of ring:");
 scanf("%d",&ir);
 printf("\nEnter the outer radius of ring:");
 scanf("%d",&or);

 peri=2*3.14*(ir*or);
 printf("\nPrimeter of ring:%f",peri);
 area=3.14*((ir*ir)-(or*or));
 printf("\nArea of ring:%f",area);

 getch();
}
/*

Finding the perimeter and area of ring:                                        
Enter the inner radius of ring:15                                              
                                                                               
Enter the outer radius of ring:16                                              
                                                                               
Primeter of ring:1507.199951                                                   
Area of ring:-97.339996                                                        
                                                                               
   */

Exercise 1-To demonstrate the use of data types, simple operators and expressions - 5

 5. Accept two numbers and print arithmetic and harmonic mean of the two numbers (Hint: AM=

(a+b)/2 , HM = ab/(a+b) )


#include<stdio.h>
#include<conio.h>

void main()
{
 int a,b;
 float am,hm;
 clrscr();

 printf("\nFinding the arthmatic mean and harmonic mean:");
 printf("\nEnter the 2 nos:");
 printf("\nEnter the first no:");
 scanf("%d",&a);
 printf("\nEnter the second no:");
 scanf("%d",&b);

 am=(a+b)/2;
 printf("\nArthmatic mean:%f",am);

 hm=a*b/(a+b);
 printf("\nHarmonial mean:%f",hm);

 getch();
}


/*

Finding the arthmatic mean and harmonic mean:                                  
Enter the 2 nos:                                                               
Enter the first no:                                                            
4                                                                              
                                                                               
Enter the second no:                                                           
5                                                                              
                                                                               
Arthmatic mean:4.000000                                                        
Harmonial mean:2.000000                                                        
*/

Questions

  Exercise 1 Set A . Apply all the three program development steps for the following examples.  1. Accept dimensions of a cylinder and p...