You are on page 1of 8

INDIRA GANDHI INSTITUTE OF TECHNOLOGY

SUBJECT:-C programming
ASSIGNMENT 1
Name:-Snigdha Pattanaik
Branch:-Mechanical Engineering
Roll no.:-393097
Regd no.:-2001105507
EXPERIMENT 1
1. Write a C program to display “This is my first C program”.
#include <stdio.h>

int main(){
   //printf()displays the string inside quotation
  
     printf("This is my First C program.");
   return 0;
}

OUTPUT
This is my First C program.

2.Write a C program to add two numbers (2 and 6) and display its sum.
#include <stdio.h>

int main()
{

  int a;
  int b;
  int x = a+b;
  printf("Enter the first number");
  scanf("%d", &a);
  printf("Enter the second number");
   scanf("%d",&b);
  printf("The sum is:%d \n", x=a+b);
 
  return 0;
}

OUTPUT
3. Write a C program to multiply two numbers (4 and 5) anddisplay its product.

4. #include <stdio.h>
5.
6. int main()
7. {
8.
9.   int a;
10.   int b;
11.   int x = a*b;
12.   printf("Enter the first number");
13.   scanf("%d", &a);
14.   printf("Enter the second number");
15.    scanf("%d",&b);
16.   printf("The result is:%d \n", x=a*b);
17.  
18.   return 0;
19. }

OUTPUT

4. Write a C program to calculate area and circumference and area of a circle.


AREA
#include <stdio.h>

int main()
{
  float r;
  float Area = (22 * r * r)/7;
  printf("Enter the radius");
  scanf("%f", &r);

  printf("The result is:%f \n", Area = (22 * r * r)/7);

  return 0;
}
OUTPUT

CICUMFERENCE

#include <stdio.h>

int main()
{
  float r;
  float circumference = 2*(22/7)*r;
  printf("Enter the radius");
  scanf("%f", &r);

  printf("The result is:%f \n", circumference =2*(22/7)*r);

  return 0;
}

OUTPUT

5.Write a C program to perform addition, subtraction, division and multiplication of two


numbers.
#include <stdio.h>

int main()
{
  float a;
  float b;
  float p=a+b;
  float q=a-b;
  float r=a*b;
  float s=a/b;
  printf("The first number is");
  scanf("%f", &a);
  printf("The second number is");
  scanf("%f", &b);
  printf("The addition of the above numbers is:%f \n",p=a+b );
  printf("The subtraction of the above numbers is:%f \n",q=a-b);
  printf("The multiplication of the above numbers is:%f \n",r=a*b );
  printf("The diision of the above numbers is:%f \n",s=a/b );
 
  return 0;
}

OUTPUT

6.Write a C program to evaluate each of the following equations.


i. v=u+at
#include <stdio.h>

int main()
{
  float u;
  float a;
  float t;
  float v=u+a*t;
  
  printf("The value of u is");
  scanf("%f", &u);
  printf("The value of a is");
  scanf("%f", &a);
  printf("The value of t is");
  scanf("%f", &t);
  printf("The result of above operation is:%f \n",v=u+a*t );
  return 0;
}

OUTPUT
ii. s=ut+1\2 at^2
#include <stdio.h>

int main()
{
  float u;
  float a;
  float t;
  float s=(u*t)+(a*t*t)/2;
  
  printf("The value of u is");
  scanf("%f", &u);
  printf("The value of a is");
  scanf("%f", &a);
  printf("The value of t is");
  scanf("%f", &t);
  printf("The result of above operation is:%f \n",s=(u*t)+(a*t*t)/2 );
  return 0;
}

OUTPUT

iii.T=2a+b^1\2+9c
#include <stdio.h>
#include <math.h>

int main()
{
  float a;
  float b;
  float c;
  float T=(2*a)+sqrt(b)+9*c;
  
  printf("The value of a is");
  scanf("%f", &a);
  printf("The value of b is");
  scanf("%f", &b);
  printf("The value of c is");
  scanf("%f", &c);
  printf("The result of above operation is:%f \n",T=(2*a)+sqrt(b)+9*c);
  return 0;
}

OUTPUT

iv. H=sqrt(b^2+p^2)
#include <stdio.h>
#include <math.h>

int main()
{
  float p;
  float b;
  float H=sqrt(b*b+p*p);
  
  printf("The value of p is");
  scanf("%f", &p);
  printf("The value of b is");
  scanf("%f", &b);
  printf("The result of above operation is:%f \n",H=sqrt(b*b+p*p) );
  return 0;
}

OUTPUT

You might also like