#include <stdio.h>
#include <conio.h>
#include <math.h>
float area_rect( float, float );
main()
{
clrscr();
float l, b, area;
printf( " \nEnter the length and breadth of the rectangle " );
scanf( " %f %f ", &l, &b );
area = area_rect ( l , b );
printf( " \nArea of rectangle is : %f square units. ", area );
return 0;
}
float area_rect ( float l, float b )
{
float area;
area = l * b;
return( area );
}
OUTPUT:
Enter the length and breadth of the rectangle
6
4
Area of rectangle is : 24.000000 square units.
Sample C Program To Find The Sum Of N Numbers.
#include <stdio.h>#include <conio.h>
main()
{
int n, sum = 0, c, var;
printf( " Enter the number of integers you want to add\n " );
scanf( " %d ", &n);
printf( " Enter %d numbers\n ", n );
for ( c = 1 ; c <= n ; c++ )
{
scanf( " %d ", &var );
sum = sum + var;
}
printf( " Sum of entered numbers = %d\n ", sum );
getch();
return 0;
}
OUTPUT:
Enter the number of integers you want to add: 3
Enter 3 numbers 1 2 3
Sum of entered numbers = 6
ALSO READ:
-- Program To Print First Ten(10) Natural Numbers.
-- Program To Print Fibonacci Series Upto 100.
-- Program To Check Whether A Number Is Prime Or Not.
-- Program To Compute The Reverse Of A Number.
-- Program To Print A Semicolon Without Using A Semicolon.
-- Program To Display Function Without Using The Main Function.
-- Program To Print Any Print Statement Without Using Semicolon.
-- Program To Display Its Own Source Code As Its Output.
-- Program To Swap Two Strings Using strcpy() Function.
-- Program to accept a string and print the reverse of the given string.
-- Program To Get IP Address.
-- Program To Accept An Integer & Reverse It.
-- Program To Convert Given Number Of Days To A Measure Of Time Given In Years, Weeks & Days.
-- Program To Illustrate The Concept Of Unions.
-- Program To Find The Size Of A Union.
... Back To C++ Programs Index
... Back To C++ FAQ's Index
... Back To C Programs Index
... Back To C FAQ's Index
... Back To HR Interview Index
Your answers seems helpful and easy to understand..Actually these kind of problems are very time consuming and with your solution its gonna be easy to save the time.
ReplyDelete