0% found this document useful (0 votes)
2 views1 page

C Assignment

The document outlines basic programming concepts in C, including the purpose of #include for standard input-output functions and the use of comments for clarity and documentation. It provides example programs for calculating the area and perimeter of a circle and rectangle, as well as determining if a number is positive, negative, or zero. Each program includes necessary code snippets demonstrating the functionality.

Uploaded by

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

C Assignment

The document outlines basic programming concepts in C, including the purpose of #include for standard input-output functions and the use of comments for clarity and documentation. It provides example programs for calculating the area and perimeter of a circle and rectangle, as well as determining if a number is positive, negative, or zero. Each program includes necessary code snippets demonstrating the functionality.

Uploaded by

remote6730
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment 1 - Programming in C

1. Purpose of #include
It includes standard input-output functions like printf() and scanf().

2. Uses of Comments
Used for explanation, readability, debugging, and documentation.

8. Program: Area & Perimeter of Circle


#include <stdio.h>
int main() {
float r, area, p;
scanf("%f",&r);
area = 3.14*r*r;
p = 2*3.14*r;
printf("Area=%.2f\nPerimeter=%.2f",area,p);
return 0;
}

10. Rectangle Program


#include <stdio.h>
int main(){
float l,b;
scanf("%f%f",&l,&b);
printf("Area=%.2f\nPerimeter=%.2f",l*b,2*(l+b));
return 0;
}

13. Positive or Negative


#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
if(n>0) printf("Positive");
else if(n<0) printf("Negative");
else printf("Zero");
return 0;
}

You might also like