Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Showing posts with label Display integers per line. Show all posts
Showing posts with label Display integers per line. Show all posts

Wednesday, March 10, 2010

To display the numbers in the series, only 7 numbers per line

To display a series of numbers as 1 2 3 4 .......... 100. Display only five integers per line.


#include<stdio.h>
#include<conio.h>
void main( )
{
int j, p=0;
for (j=1; j < = 100, j++)
{
printf("%d", j);
p++;
if (p==7)
{
printf("\n");
p=0;
}
}
}

Hint:-


Method used in previous question can not be used
here. That method can be used only if 80 divided by
number of values per line gives you integer answer
otherwise you have to use 2nd Method.
7 values per line = 80/7 = 11.43 and
therefore you can not use the earlier method.

read more "To display the numbers in the series, only 7 numbers per line"

Tuesday, March 2, 2010

Write a program in C to display the number from 1 to 200 in a series. Print 20 numbers on one line and use all the available columns on the screen.

Write a program in C to display the number from 1 to 200 in a series.
Print 20 numbers on one line and use all the available columns on the screen.


#include<stdio.h>
#include<conio.h>
main( )
{
int i;
clrscr( );
for (i=1; i < = 200; i++)
{
printf("%4d", i);
}
return(0);
}

Hint:-


20 values per line = 80/20 = 4 = %4d
4 values per line = 80/4 = 20 = %20d
8 values per line = 80/8 = 10 = %10d


read more "Write a program in C to display the number from 1 to 200 in a series. Print 20 numbers on one line and use all the available columns on the screen."

Write a program in C to display the number form 1 2 3 4 .................100. Display only five integers per line.

Write a program in C to display the number form 1 2 3 4 .................100.
Display only five integers per line.


#include<stdio.h>
#include<conio.h>
main( )
{
int i;
clrscr( );
for (i=1; i < = 100; i++)
{
printf("%16d", i);
} return(0);
}

Hint:-


5 values per line = 80/5 = 16 = %16d
4 values per line = 80/4 = 20 = %20d
8 values per line = 80/8 = 10 = %10d


read more "Write a program in C to display the number form 1 2 3 4 .................100. Display only five integers per line."

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP