-->

program to input and display single character



// program to input single character and display it
#include<stdio.h>
#include<conio.h>
void main()
{
char a;
printf(“enter a single character\n”);
scanf(“%c”,&a); // we can also use a=getchar()
printf(“the character=%c\n”,a); // we can also use putchar(a)
getch();
}

note:
getchar() function is only used to input a single character and
putchar() is only for one character display

program to convert paisa to rupees

// program to convert paisa to rupees
#include<stdio.h>
#include<conio.h>
void main()
{
float paisa;
float rupees;
printf(“enter amount of paisa\n”);
scanf(“%f”,&paisa);
rupees=paisa/100;
printf(“the area is=%f\n”,rupees);
getch();
}

program to get area of triangle using perimeter concept

// program to get area of triangle using perimeter concept
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c;
float s,area,peri;
printf(“enter sides of triangle\n”);
scanf(“%f%f%f”,&a,&b,&c);
s=a+b+c;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf(“the area is=%f\n”,area);
getch();
}

program to get area of square

// program to get area of square
#include<stdio.h>
#include<conio.h>
void main()
{
float length;
float area;
printf(“enter base and height of square\n”);
scanf(“%f”,&length);
area=length*length;
printf(“the area is=%f\n”,area);
getch();
}

program to get area of parallelogram

//program to get area of parallelogram
#include<stdio.h>
#include<conio.h>
void main()
{
float base,height;
float area;
printf(“enter base and height of parallelogram\n”);
scanf(“%f%f”,&base,&height);
area=base*height;
printf(“the area is=%f\n”,area);
getch();
}

program to get simple interest and amount

//program to get simple interest
#include<stdio.h>
#include<conio.h>
void main()
{
float p,r,t;
float interest,A;
printf("enter principal,rate of interest and time\n");
scanf("%f%f%f",&p,&r,&t);
interest=(p*t*r)/100;
A=p+interest;
printf("the interest gained is=%f\n",interest);
printf("the amount after interest=%f\n",A);
getch();
}

Solution6



// program to get ‘v’ using given formula v2=u2+2as
#include<stdio.h>
#include<conio.h>
#include<math.h> //for sqrt() and pow() function
void main()
{
float u,a,s;
float v;
printf(“enter  value of ‘u’\n”);
scanf(“%f”,&u);
printf(“please enter value of ‘s’\n”);
scanf(“%f”,&s);
printf(“please enter value of ‘a’\n”);
scanf(“%f”,&a);
v=sqrt(pow(u,2)+2*a*s);
printf(“the value of 'v'=%f\n”,v);
getch();
}