Input rows and columns manually. Like this:
input column: 3
input row: 2
then the output must be:
1 2 3
2 4 6
it's continuous. so if I enter new number in columns and row, it will display the numbers included.

What is the code applicable for this. I really need this. :sad:

Recommended Answers

All 4 Replies

I think you should start by using scanf to read in the number of rows and columns into two variables.
Post this when you've written it.

I think you should start by using scanf to read in the number of rows and columns into two variables.
Post this when you've written it.

yes thank you! I'm just a beginner. but this is the code and i used scanf function.
#include<stdio.h>
int r,c,x,y;
main()
{
clrscr();
printf("Input column:");
scanf("%d",&c);
printf("Input row:");
scanf("%d",&r);
for(x=1;x<=r;x++)
{
for(y=1;y<=c;y++)
printf("\t%d",x*y);
printf("\n");
}
printf("\t");
getch();
}

yes thank you! I'm just a beginner. but this is the code and i used scanf function.
#include<stdio.h>
int r,c,x,y;
main()
{
clrscr();
printf("Input column:");
scanf("%d",&c);
printf("Input row:");
scanf("%d",&r);
for(x=1;x<=r;x++)
{
for(y=1;y<=c;y++)
printf("\t%d",x*y);
printf("\n");
}
printf("\t");
getch();
}

I am sorry I have another question how about this one?

I'm sorry I'm just a new Computer science Student and I have difficulty in codes. :(
The user is asked to input the number of days in a month and the first day of the month. Here is the sample output:
Input the number of days in a month: 30
input the first day of the month: 4
0-Sunday
1-Monday
2-Tuesday
3-Wednesday
4-Thursday
5-Friday
6-Saturday

Sun Mon Tues Wed Thurs Fri Sat
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

This is my sample code. I enter 1-6 in the first day of the month and it works...but everytime I enter O in the first day of the month, the alignment is lost. Help!!! i tried to fix it several times but i can't!!!
#include<stdio.h>
#define p printf
#define s scanf
int TD,D,x,y=1,E;
main()
{
clrscr();
p("Input Number of days in a month:");
s("%d",&TD);
p("Input the first day of the month:");
s("%d",&D);
p("Sun\tMon\tTues\tWed\tThurs\tFri\tSat\n");
for(x=1;x<=42;x++)
{
if(x<=D)
{
printf("\t");
}
else if(y<=TD)
{
E=7-D;
if(y%7==D)
{
printf("%d\n",y);
}
else
{
printf("%d\t",y);
}
y++;
}}
getch();
}

@civirol02:

I just answered this question in your other calendar display thread.

Please, just one program per thread, or you'll wind up wasting a great deal of our time.

The calendar display problem is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.