Chapter 2 Programs
1. Program to display message “welcome to polytechnic”
2. Program to perform addition of two integer number.
3. Program for average of three numbers
4. program to find Area of triangle, Area of rectangle.
5. Program to find square of a number
6. Program to find cube of a number
7. Program to convert Fahrenheit temperature to Celsius temperature.
8. Program for simple marksheet.
1 #include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf(“welcome to polytechnic”);
getch();
}
2 // program for addition of two number
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter the 1st no.");
scanf("%d",&a);
printf("enter the second no.");
scanf("%d",&b);
c=a+b;
printf("answer = %d",c);
getch();
}
3 //average of 3 nos.
#include<stdio.h>
#include<conio.h>
main()
{
int n1,n2,n3;
float r;
clrscr();
printf("\nEnter the first number ");
scanf("%d",&n1 );
printf("\nEnter the second number ");
scanf("%d",&n2);
printf("\nEnter the third number ");
scanf("%d",&n3);
r=(n1+n2+n3)/3;
printf("\n The average of three number is %f",r);
getch();
}
4 //to display the area of rectangle
#include<stdio.h>
#include<conio.h>
main();
{
int l,b;
float r;
clrscr();
printf("Enter the length of rec.");
scanf("% d",&l );
printf("\nEnter the breadth of the rectangle ");
scanf("%d",&b);
r=l*b;
printf("\narea of the circle is %f",r);
getch();
}
5 //To display the square
#include<stdio.h>
#include<conio.h>
main()
{
int a;
float r;
clrscr();
printf(" Enter the value of a ");
scanf("%d",&a);
r=a*a;
printf("\n The square is %f", r);
getch();
}
6 //To display the cube
#include<stdio.h>
#include<conio.h>
main()
{
int a;
float r;
clrscr();
printf(" Enter the value of a ");
scanf("%d",&a);
r=a*a*a;
printf("\n The cube is %f", r);
getch();
}
7 //To display the degree celcius
#include<stdio.h>
#include<conio.h>
main()
{
int f,c;
clrscr();
printf("Enter the value of f ");
scanf("%d",&f);
c=(f-32)/5;
printf("\nValue of c is %d",c );
getch();
}
8 //display the marksheet
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<string.h>
main()
{
char n[25],grad[25];
int roll,s1,s2,s3,total;
float per;
clrscr();
printf("\n Enter the Name of the student ");
scanf("%s",n);
printf("\n Enter the roll number of student ");
scanf("%d",&roll);
printf("\nEnter the marks of first subject ");
scanf("%d",&s1);
printf("\nEnter the marks of the second subject ");
scanf("%d",&s2);
printf("\nEnter the marks of the third subject ");
scanf("%d",&s3);
total =s1+s2+s3;
per = total/3;
clrscr();
printf("\n***************************************************************");
printf("\n S.H.H.J.B.Polytechnic ");
printf("\n Neminath,Neminagar,Chandwad ");
printf("\n**************************************************************** ");
printf("\n Name of the student = %s",n);
printf("\n Roll number of student = %d",roll);
printf("\n PHYSICS = %d",s1);
printf("\n MATHS = %d",s2);
printf("\n C PROGRAM = %d",s3);
printf("\n\n TOTAL = %d",total);
printf("\n percentage = %f",per);
printf("\n\n\n\t\t\t\t\t\t\n\n class teacher signature");
getch();
return 0;
}