You are on page 1of 1

COMPUTER PROGRAMMING LAB

Assignment 1
1. Write a program in C to input the marks of three subjects from the user and find the
sum and average of these marks.
//Program1
#include<stdio.h>
int main(){
int a,b,c;
printf("Enter the marks of all the three subjects one by one: \n");
scanf("%d %d %d",&a,&b,&c);
printf("The sum of marks is %d .",a+b+c);
printf("The average of marks is %f .",(a+b+c)/3.0);
return 0;}
OUTPUT:

2. Write a program to input the length and breadth of the rectangle from the user and
print its area and perimeter.

//Program2
#include<stdio.h>
int main(){
float a,b;
printf("Enter the length and breath of the rectangle one by one in meters: \n");
scanf("%f %f",&a,&b);
printf("The area of the rectangle is %f sq. meters and its perimeter is %f
meters.",a*b,2*(a+b));
return 0;}
OUTPUT:

You might also like