Write a C Program to perform the following.
Display the number 34.789 in a field of nine spaces with two decimal places of
precision.
Display the number 7.0 in a field of five spaces with three decimal places of
precision. The decimal point and any trailing zeroes should be displayed.
Display the number 5.789e+12 in fixed point notation.
Display the number 67 left justified in a field of seven spaces.
Answers
Answered by
2
Given below are the programs in C language.
Explanation:
- (1) #include<stdio.h>
- int main(){
- float num=34.789;
- prinf ("%9.2f" ,num); }
- (2) #include<stdio.h>
- int main(){
- float num= 7.0;
- printf("%5.3f" ,num); }
- (3) #include <iostream>
- using namespace std;
- int main(){
- double num= 5.789e12;
- cout<< fixed<< num<<endl; }
- (4) #include <stdio.h>
- int main{
- int num=67;
- printf("%-7d" ,num); }
Similar questions
Psychology,
3 hours ago
Physics,
3 hours ago
English,
5 hours ago
Political Science,
8 months ago
Math,
8 months ago