About Me

My photo
Vijayapur, Karnataka, India
I am interested in Teaching.

Monday 24 August 2020

Important C programs for C for Problem Solving for I and II sem of Engineering Students (As per VTU)

 C program to calculate simple interest.


# include<stdio.h>
void main()
{
float p, t, r, si;


printf("Enter P T R ");
scanf("%f%f%f",&p,&t,&r);


si=(p*t*r)/100;


printf("\n Simple Interest is %f", si);
}


Output:
Enter P T R 
100 5 5 [Enter Key]
Simple Interest is 
25.00


 C program to calculate area and perimeter of rectangle.


# include<stdio.h>
void main()
{
float l, b, area, per;


printf("Enter length and breadth of rectangle  ");
scanf("%f%f", &l, &b);

area=l*b;

per=2*(l+b);


printf("\n Area of rectangle is %f", area);

printf("\n Perimeter rectangle is %f", per);

}


Output:
Enter length and breadth of rectangle
10 20 [Enter Key]
Area of rectangle is 200.00
Perimeter of rectangle is 60.00


C program to check for PALINDROME or not.


# include<stdio.h>
void main()
{
int n, rem, rev=0, temp;


printf("Enter a number to be check   ");
scanf("%d",&n);

temp=n;

while (n!=0)

{
rem=n%10;
rev=(rev*10)+rem;
n=n/10;
}

if (rev==temp)

printf("\n PALINDROME");

else

printf("\n NOT Palindrome ");

}


Output:

Enter a number to be check

123
NOT Palindrome

Output:

Enter a number to be check

121
PALINDROME


No comments:

GCD of two numbers and its application...

The greatest common divisor (gcd) of two numbers is the largest positive integer that divides both numbers without leaving a remainder. The ...