Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Tuesday, February 16, 2010

Write the output for the following C program



#define p(a,b) (a+b)/2
main( )
{
int x=4, y=9, h;
x+=y++;
y*=3;
h=p(x,y);
printf("%5d %5d %5d\n", x, y, h);
}

Output :-
_ _ _ 13 _ _ _ 30 _ _ _ 21
read more "Write the output for the following C program"

Write the output for the following C program



#include<stdio.h>
main( )
{
int a, b;
for (a=2, b=4; a < 100; b+=4, a*=3)
{
a+=b;
printf("%4d", a);
}
}

Output :-
_ _ _ 6 _ _ 26 _ _ 90
read more "Write the output for the following C program"

Write the output for the following C program ?



main( )
int x=3, y=5, n;
while (y < 30)
{
n=x+y;
printf("%3d", n);
x=y;
y=n;
}
}

Output :-
_ _ 8 _ 13 _ 21 _ 34
read more "Write the output for the following C program ?"

Write the output for the following C program



#define h(a , b) a > b ? a : b
main( )
{
int x=25, y=33, z=10;
x+=3*y++;
y*=3;
z+=h(x,y);
printf("%d \n %d\n %d \n", x, y, z);

Meaning :-
h(a,b) = a if condition a >b is true.
h(a,b) = b if condition a >b is not true.

Output
124
102
134
read more "Write the output for the following C program"

Write the output for the following C program



#define f(x) x > = 0 ? "real" : "complex"
main( )
{
int a=2, b=7, c=7, d;
d = (b*b-4*a*c);
printf("\n d is a %s values", f(d));
}

Meaning:-
f(x) will be real if x>0
f(x) will be complex if the above condition is not true.

Output :-
d is a complex values
read more "Write the output for the following C program"

Thursday, February 11, 2010

Write the output for the following C program



main( )
{
int a = 2, s = 0, j = 1;
for ( ; a < 10; a+=3, j++)
{
s += a * a * a;
printf("\n a = %d j = %d", a, j);
}
printf("\n j=%d a=%d s=%d", j, a, s);
}


























Output


a=2
j=1

a=5
j=2

a=8
j=3

j=4
a=11
s=645
read more "Write the output for the following C program"

Write a output for the following c program



#include<stdio.h>
main( )
{
int x = 6589;
char z = '*';
float y = 8888.9935;
printf("% -6.1f %3c\n", y, z);
printf("% +5d % -3c\n", x, z);
}

Ouput:-

8889.0 _ _ *
+6589 * _ _
read more "Write a output for the following c program"

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"

Wednesday, February 10, 2010

Output of an integer number

Following is the format for an integer output namely %wd where 'w' specify the minimum field width necessary to print the integer value.

if w > 0 then the printing is right justified
if w < 0 then the printing is left justified

For eg:- Let a = 3248





















Statement
Output
printf("%d",a);
3248
printf("%7d",a);
_ _ _3248
printf("%10d",a);
_ _ _ _ _ _3248
printf("% - 6d",a);
3248_ _
printf("% - 9d",a);
3248_ _ _ _ _
printf("% - 15d",a);
3248_ _ _ _ _ _ _ _ _ _ _
read more "Output of an integer number"

Various types of outputs

1) Output of an integer number
2) Output of a float number
3) Output of a character constant
4) Output of string
read more "Various types of outputs"

Tuesday, February 9, 2010

What is the output of following C program ?



#include<stdio.h>
void main( )
{
int i, j;
for ( i = 1, j = 2; i < 5, j < 5; i++, j++)
{
printf("i = %d\t j = %d\n", i, j);
printf("i = %d\t j = %d\n", i, j);
}
}


































Output

i=1
j=2
i=1

j=2

i=2
j=3
i=2

j=3

i=3
j=4
i=3

j=4



read more "What is the output of following C program ?"

What is the output of the following in C - program ?



#include<stdio.h>
void main( )
{
int i, j;
for ( i = 1, j = 2; i < 5 , j < 3; i++, j++)
{
printf("i = %d \t j = %d\n", i, j);
printf("i = %d\n j = %d \n", i, j);
}
}




















Output


i=1
j=2

i=1


j=2


read more "What is the output of the following in C - program ?"

Friday, February 5, 2010

What is the output of the following C program





#include<
stdio.h>
void main( )
{
int a=2, j=1, s=0;
for (j++, a=2; a<10; a + =3)
{
s=a*a;
printf("a=%d \t j="%d s=%d\n" , a, j, s);
}
}

























Output


a=2
j=2
s=4
a=5
j=2
s=25
a=8
j=2
s=64
read more "What is the output of the following C program"

Thursday, February 4, 2010

Write the Output for the following program in c



#include<stdio.h>
void main( )
{
int i, j;
for (i=1, j=2; i < 5; i++, j++)
{
printf("i = %d \t j = %d \n" , i, j);
}
}

















Output

i=1
j=2
i=2
j=3
i=3
j=4
i=4
j=5
read more "Write the Output for the following program in c"

Wednesday, February 3, 2010

Write a program in c to display the simple interest

Write a program in c to display the simple interest table from 1st year to 10th year for the principle amount (p) Rs. 10,000/- and the rate of interest (r)2% p.a. with the formula si = p*n*r/100



#include<stdio.h>
#include<conio.h>
#include<math.h>
main( )
{
clrscr( );
int n;
float p, r, si;
p = 10000;
r = 2;
printf("\t Simple interest table\n");
printf("\n Year\t Interest(Rs.)\n");
for (n=1; n < =10; n++)
{
si = p*n*r/100;
printf("%d\t%f\n", n, si);
}
return(0);
}

Output




































Simple Interest Table
Year Interest(Rs.)
1 200.000000
2
400.000000
3
600.000000
4
800.000000
5
1000.000000
6
1200.000000
7
1400.000000
8
1600.000000
9
1800.000000
10
2000.000000

read more "Write a program in c to display the simple interest"

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP