Itp File - 1
Itp File - 1
Itp File - 1
#include<stdio.h>
int main()
{
int p,r,t,int_amt;
printf("Input principle, Rate of interest & time to find simple interest: \n");
scanf("%d%d%d",&p,&r,&t);
int_amt=(p*r*t)/100;
printf("Simple interest = %d",int_amt);
return 0;
}
Output
Program : 2 Write a program to swap two number with the
help of third variable.
#include <stdio.h>
int main()
{
int var1, var2, temp;
printf("Enter two integersn");
scanf("%d%d", &var1, &var2);
printf("Before SwappingnFirst variable = %dnSecond variable = %dn", var1,
var2);
temp = var1;
var1 = var2;
var2 = temp;
printf("After SwappingnFirst variable = %dnSecond variable = %dn", var1,
var2);
return 0;
}
Output
Program 3 :Write a program to swap two number without the
help of third variable.
#include<stdio.h>
int main()
a=a+b;
b=a-b;
a=a-b;
return 0;
Output
Program 4 : Convert temperature in Celsius to fah
#include<stdio.h>
void main()
float celsius,fahrenheit;
scanf("%f",&celsius);
return 0;
Output
Program 5 : Write a program to find area of triangle using
heron’s formula
#include<stdio.h>
#include<math.h>
int main()
float a, b, c, s, Area;
scanf("%f%f%f",&a,&b,&c);
s = (a+b+c)/2;
Area = sqrt(s*(s-a)*(s-b)*(s-c));
return 0;
Output
Program 6 : Write a program to implement Logical operator
#include <stdio.h>
int main()
int a = 8, b = 7, c = 7, result;
return 0;
}
Output
Program 7 : Write a program to implement Relational
operator
#include <stdio.h>
int main()
int a = 7, b = 5, c = 8;
return 0;
}
Output
Program 8 : Write a program to implement Bitwise operator
#include <stdio.h>
int main()
printf("Output = %d\n",~-a);
return 0;
Output
Program 9 : Largest of two numbers using
conditional/ternary operator.
#include<stdio.h>
void main()
int a,b,larg;
scanf("%d %d",&a,&b);
larg = a>b?a:b;
return 0;
Output
Program 10 : Program to check whether two numbers are
equal or not using conditional/ternary operator.
#include<stdio.h>
void main()
int a,b;
scanf("%d %d",&a,&b);
Output
Program 11 : Largest of three numbers using
conditional/ternary operator.
# include <stdio.h>
void main()
int a, b, c, big ;
Output
Program 12 : whether a number is even or odd
#include <stdio.h>
int main() {
int num;
scanf("%d", &num);
if(num % 2 == 0)
else
return 0;
Output
Program 13 : Write a program to find sum of 4-digit
number.
#include <stdio.h>
int main()
int n,f,x,s,y,t,l,sum;
scanf("%d",&n);
f=n/1000;
x=n%1000;
s=x/100;
y=x%100;
t=y/10;
l=y%10;
sum=f+s+t+l;
return 0;
}
Program 14 : write a program to reverse a three digit number
#include <stdio.h>
int main()
scanf("%d", &n);
num1 = n / 100;
num3 = n%10 ;
return 0;
}
Program 15 :Write a program to convert no. of days into
years, months and days.
#include <stdio.h>
int main() {
int ndays, y, m, d;
scanf("%d", &ndays);
y = (int) ndays/365);
ndays = ndays-(365*y);
m = (int)ndays/30;
d = (int)ndays-(m*30);
return 0;
}
Program 16 : largest of two numbers using if-else
#include <stdio.h>
int main()
return 0;
Output
Program 17 : largest of three numbers using if-else
#include <stdio.h>
int main() {
else
return 0;
}
Output
Program 18 : Write a C program to input electricity unit
charge and calculate the total electricity bill according to the
given condition:
int main()
int unit;
scanf("%d", &unit);
{
amt = 25 + ((unit-50) * 0.75);
else
return 0;
}
Output
Program 19 : Write a c program to Arrange 3 numbers in
increasing order.
#include<stdio.h>
void main()
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if((a>=b)&&(a>=c))
if(b>=c)
else
else if((b>=a)&&(b>=c))
if(a>=c)
else
else if((c>=a)&&(c>=b))
if(a>=b)
else
Output
Program 20 : If the basic salary is less than Rs 1500 ,then
HRA is 10% of the basic salary and DA is 90% of basic salary
if the salary is either equal to or above 1500 then HRA is 500
and DA is 95% of basic salary .if the employee salary is
entered then find the gross salary and display it.
#include<stdio.h>
int main()
if (bs<1500)
hra=bs*10/100;
da=bs*90/100;
else
hra=500;
da=bs*95/100;
Output
Program 21 : to check whether vowel or not by switch case
#include <stdio.h>
int main()
char ch;
scanf("%c", &ch);
switch(ch)
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
printf("It is a Vowel");
break;
default: printf("Consonant");
return 0;
Output
Program 22 : Write a program for calculator using switch
case
#include <stdio.h>
int main() {
char operator;
scanf("%c", &operator);
switch (operator) {
case '+':
break;
case '-':
break;
case '*':
break;
case '/':
printf("%.1lf / %.1lf = %.1lf", first, second, first / second);
break;
default:
return 0;
Output