Get Email Subscription

Enter your email address:

Delivered by FeedBurner

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