Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Thursday, February 11, 2010

Write a output for the following c program



#include<stdio.h>
mani( )
{
int x = 789;
float y = 6767.8787;
printf("% -8d %+9.3f\n", x, y);
printf("%+-6d % -15.2f\n", x, y);
}

Output:-

789 _ _ _ _ _+6767.879
+789 _ _ 6767.88 _ _ _ _ _ _ _ _

read more "Write a output for the following c program"

Write a output for the following c program?



#include<stdio.h>
mani( )
{
char x = '&';
float y = 2134.627;
printf("%3c %9.2f\n", x, y);
printf("% -4c -7.0f\n", x, y);
return(0);
}

Output:-

_ _ & _ _ 2134.63
& _ _ _ 2135 _ _ _
read more "Write a output for the following c program?"

Write a output for the following c program?



mani( )
{
int a = 1235, b = -1888;
float x = 2233.44, y = 4455.66;
printf("% -6d % -6d\n", a, b);
printf("% -8.2f % -10.1f\n", x, y);
}

Output:-

1235_ _-1888_
2233.44_ 4455.7_ _ _ _
read more "Write a output for the following c program?"

Write a output for the following in C program



mani( )
{
int a = 1235, b = -1888;
float x = 2233.44, y = 4455.66;
printf("%6d %6d\n", a, b);
printf("%+8.2f %+10.1f\n", x, y);
}

Output:-

_ _ 1235_-1888
+2233.44_ _ _ +4455.7
read more "Write a output for the following in C program"

Output of string

The format of this output is %w.ps where 'w' shows the minimum field width and 'p' shows that only the first p character will be printed.

If w > 0 then the printing is right justify.
If w < 0 then the printing is left justify.

For eg:- name = "SEETA AUR GEETA"





















Statement
Output
printf("%15s",name);
SEETA_AUR_GEETA
printf("%10.6s",name);
_ _ _ _SEETA_
printf("%9.3s",name);
_ _ _ _ _ _SEE
printf("% - 10.7s",name);
SEETA_A_ _ _
printf("% - 12.9s",name);
SEETA_AUR_ _ _


read more "Output of string"

Output of a character constant

This output has the following format.

%wc

If w > 0 then the printing is right justify.
If w < 0 then the printing is left justify.

For eg:- let a = 'Q'





















Statement
Output
printf("%4c",a);
_ _ _ Q
printf("%8c",a);
_ _ _ _ _ _ _ Q
printf("%5c",a);
_ _ _ _ Q
printf("% - 7c",a);
Q _ _ _ _ _ _
printf("% - 4c",a);
Q_ _ _
printf("% 12c",a);
_ _ _ _ _ _ _ _ _ _ _ Q
read more "Output of a character constant"

Output of a float number

The format for this output is %w.pf where 'w' specify the minimum field width and 'p' specify the number of position after the decimal point

If w > 0 then the printing is right justify.
If w < 0 then the printing is left justify.

For eg:- a = 32.289





















Statement
Output
printf("%f",a);
32.289
printf("%8.3f",a);
_ _32.289
printf("%10.2f",a);
_ _ _ _ _32.29
printf("% - 7.3f",a);
32.289_
printf("% - 11.3f",a);
32.289_ _ _ _ _
printf("% 11.4f",a);
_ _ _ _32.2890
read more "Output of a float number"

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP