0% found this document useful (0 votes)
11 views4 pages

Assignment 5

Uploaded by

talent.thread
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Assignment 5

Uploaded by

talent.thread
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ASSIGNMENT -5 (BASICS OF C PROGRAMMING)

Basic instructions:
1. Check every line of your program for semicolon (;)
2. Check printf for format specifier %d for integer numbers
3. Check scanf for %d and & sign before variable name

 Aman’s basic salary is input through the keyboard. His


dearness allowance is 50% of basic salary, and house rent
allowance is 20% of basic salary. Write a program to
calculate his gross (total) salary. Print the salary on screen.
 The length and breadth of a rectangle is input through the
keyboard. Write a program to calculate the area of a
rectangle. Print the area on output screen.
 #include<stdio.h>
 #include<math.h>
 int main(){
 float a,b;
 printf("enter lenght and breath : ");
 scanf("%f%f",&a,&b);
 printf("%f area",a*b);
 return 0;
 }

 The length and breadth of a rectangle is input through the


keyboard. Write a program to calculate the perimeter of a
rectangle. Print the result on output screen.

#include<stdio.h>
#include<math.h>
int main(){
float a,b;
printf("enter lenght and breath : ");
scanf("%f%f",&a,&b);
printf("%f perimeter",2*(a+b));
return 0;
}

 The side of a square is input through the keyboard. Write a


program to calculate the area of a square. Print the area on
output screen.
 #include<stdio.h>
 #include<math.h>
 int main(){
 float a,b;
 printf("enter side : ");
 scanf("%f",&a);
 printf("%f perimeter",a*a);
 return 0;
 }

 The side of a square is input through the keyboard. Write a


program to calculate the perimeter of a square. Print the
result on output screen.

#include<stdio.h>
#include<math.h>
int main(){
float a,b;
printf("enter side : ");
scanf("%f",&a);
printf("%f perimeter",4*a);
return 0;
}

 The radius of a circle is input through the keyboard. Write a


program to calculate the area of a circle. Print the area on
output screen.
 #include<stdio.h>
 #include<math.h>
 int main(){
 float a;
 printf("enter radius of circle : ");
 scanf("%f",&a);
 printf("%f area",a*a*3.14);
 return 0;
 }

 The radius of a circle is input through the keyboard. Write a


program to calculate the circumference of a circle. Print
the result on output screen.

#include<stdio.h>
#include<math.h>
int main(){
float a;
printf("enter radius of circle : ");
scanf("%f",&a);
printf("%f area",2*a*3.14);
return 0;
}

 Enter the three sides of a triangle. Find the sum of three


sides of the triangle. Print the result on the screen.
 #include<stdio.h>
 #include<math.h>
 int main(){
 float a,b,c;
 printf("enter side of triangle ");
 scanf("%f,%f,%f",&a,&b,&c);
 printf("%f perimeter",a+b+c);
 return 0;
 }

 If the marks obtained by a student in five different subjects


are input through the keyboard, write a program to find
out the aggregate marks. Print the aggregate marks of the
student on screen.

#include<stdio.h>
#include<math.h>
int main(){
float a,b,c,d,e;
printf("enter maths marks ");
scanf("%f,%f,%f",&a);
printf("enter physics marks ");
scanf("%f,%f,%f",&b);
printf("enter chem marks ");
scanf("%f,%f,%f",&c);
printf("enter communication marks ");
scanf("%f,%f,%f",&d);
printf("enter civil marks ");
scanf("%f,%f,%f",&e);
printf("%.f marks",a+b+c+d+e);
return 0;
}

 Assume that the maximum marks that can be obtained by


a student in any subject is 100. If the marks obtained by a
student in five different subjects are input through the
keyboard, write a program to find out the percentage
obtained by the student. Print the percentage of the
student on screen
 #include<stdio.h>
 #include<math.h>
 int main(){
 float a,b,c,d,e;
 printf("enter maths marks ");
 scanf("%f,%f,%f",&a);
 printf("enter physics marks ");
 scanf("%f,%f,%f",&b);
 printf("enter chem marks ");
 scanf("%f,%f,%f",&c);
 printf("enter communication marks ");
 scanf("%f,%f,%f",&d);
 printf("enter civil marks ");
 scanf("%f,%f,%f",&e);
 printf("%.f final percentage",(a+b+c+d+e)*.2);
 return 0;
 }

You might also like