The printf() Function
The printf() function is used to display the output on monitor in a specified format. It is also called the formatted output function. It is most commonly used in C programs to display the output. This function is defined in the "stdio.h" header file.The syntax of 'printf()' function is as follow:
printf (format_string [ , arguments ] ) ;
Write a program to compute and print the area of a square with given height and width. The formula to compute the area of square is
Area = height * width ;
Example in C
#include < stdio.h >
#include < conio.h >
void main ( )
{
int height , width , area ;
height = 13 ;
width = 5 ;
area = height * width ;
printf ( " Area of square is : %d " , area ) ;
}
Example in C++
#include < iostream >
using namespace std ;
int main ( )
{
int height , width , area ;
height = 13 ;
width = 5 ;
area = height * width ;
cout << " Area of square is : " << area ;
return 0 ;
}
No comments:
Post a Comment
Thanks For Visiting Here...!! I will Reply you as soon as possible.