Unit : 01 – Using input and output statements, Operators

1) Write a program to print the address of INDUS.

#include<stdio.h>
#include<conio.h>
void main()
{
 clrscr();
 printf("Address : INDUS UNIVERSITY \n Racharda,via shilaj \n Ahemedabad");
 getch();
}

2) Write a program to perform basic arithmetic operators on given two numbers.

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f;
clrscr();
printf("Enter the First Number:");
scanf("%d",&a);
printf("Enter the second Number:");
scanf("%d",&b);
c=a+b;
printf("sum=%d\n",c);
d=a-b;
printf("subraction=%d\n",d);
e=a*b;
printf("Multiplication=%d\n",e);
f=a/b;
printf("Division=%d\n",f);
getch();
}

3) Find the area and perimeter of square and rectangle and circle. Input the side(s) through the keyboard. (use PIE as symbolic constant)

#include<stdio.h>
#include<conio.h>
void main()
{
	int x=2,y=4,z,a,c,d,e,f;
	float b=3.14;

	clrscr();
	printf("enter the radius of the circle:");
	scanf("%d",&a);
	printf("area of circle : %f",a*a*b);
	
//this is for square

	printf("\nenter the length:");
	scanf("%d",&d);
	printf("area of the square = %d",d*d);

//this is for rectangle
	printf("\nenter the length:");
	scanf("%d",&e);
	printf("\nenter the width:");
	scanf("%d",&f);
	printf("\narea of the rectangle = %d",e*f);

//this is for circle's peremeter
	printf("\nperemeter of circle = %f",x*b*a);
//this is for peremeter of square
	printf("\nperemeter of square = %d",y*d);
//this is for peremeter of rectangle
	z=e+f;
	printf("\nperemeter of rectangle = %d",x*z);
	getch();
}

4) Write a program to swap values of 2 variables (i) with extra variable and (ii) without using an extra variable.

#include<stdio.h>
#include<conio.h>
void main()
{

  int a,b,c;
  clrscr();
  printf("Enter first value : ");
  scanf("%d", &a);
  printf("Enter second value : ");
  scanf("%d", &b);
  printf("\nbefore swape first value : %d " ,a);
  printf("\nbefore swape second value : %d " ,b);
  c=a;
  a=b;
  b=c;
  printf("\nAfter swap First value : %d " ,a);
  printf("\nAfter swap Second value : %d " ,b);


// Now Without Using third variable

  printf("\nEnter first value : ");
  scanf("%d", &a);
  printf("Enter second value : ");
  scanf("%d", &b);
  printf("\nbefore swape first value : %d " ,a);
  printf("\nbefore swape second value : %d " ,b);
  a=a+b;
  b=a-b;
  a=a-b;
  printf("\nAfter swap First value : %d " ,a);
  printf("\nAfter swap Second value : %d " ,b);
getch();
}

5) Write a program to print the ASCII value of a given character.


#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("enter the character;");
scanf("%c" ,&ch);
printf("the ASCII_value is :%d" ,ch);
getch();
}

6) Write a program to enter the integer number and convert it into Rs and Paisa.

#include<stdio.h>
#include<conio.h>
void main()
{
	int a,b,c;
	clrscr();
	printf("Enter the valve of a:");
	scanf("%d",&a);
	b=a*1;
	printf("converted into rupees:%d\n",b);
	c=a*100;
	printf("converted into paisa:%d\n",c);
	getch();
}

7) Write a program to enter two numbers. Make the comparison between them with conditional operator. If the first number is greater than second perform multiplication otherwise division operation.

#include<stdio.h>
#include<conio.h>
void main()
{
	float a,b,c;
	clrscr();
	printf("Enter value of A:");
	scanf("%f",&a);
	printf("Enter value of B:");
	scanf("%f",&b);
	c=a>b?printf("Multiplication:%f",a*b):printf("Division:%f",a/b);
	getch();
}

8) Write a program to enter the temperature in Fahrenheit and convert it to Celsius.[C = ((F-32)*5)/9]

#include<stdio.h>
#include<conio.h>
void main()
{
	int a,b;
	clrscr();
	printf("Enter the F valve:");
	scanf("%d",&a);
	b=((a-32)*5)/9;
	printf("The C valve:%d",b);
	getch();
}

9) Write a program to calculate simple interest.

#include<stdio.h>
#include<conio.h>
void main()
{
	float p,y,r,si;
	clrscr();
	printf("Enter the valve:");
	scanf("%f",&p);
	printf("Enter the rate of interest:");
	scanf("%f",&r);
	printf("Enter the year:");
	scanf("%f",&y);
	si=(p*r*y)/100;
	printf("simple interset=%f",si);
	getch();
}

10) Write a program to enter marks of five subject of a student and calculate its average, percentage.

#include<stdio.h>
#include<conio.h>
void main()
{
   int a,b,c,d,e,f,g;
   clrscr();
   printf("Marks of English:\n");
   scanf("%d",&a);
   printf("Marks of Maths:\n");
   scanf("%d",&b);
   printf("Marks of Gujarati:\n");
   scanf("%d",&c);
   printf("Marks of computer:\n");
   scanf("%d",&d);
   printf("Marks of science:\n");
   scanf("%d",&e);
   f=a+b+c+d+e;
   printf("AVERAGE:%d\n",f/5);
  g=f/5;
   printf("percentage:%d%\n",g);
   getch();
}

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!
Scroll to Top