Friday, 8 August 2014
Let Us C eBook
This book covers these three aspects of C programming and doesn’t assume
any programming background. It begins with the basics and steadily
builds the pace, so the reader finds it easy to handle more complicated
topics later. This popular author has crafted hundreds of excellent
programming examples and exercises for every aspect of C programming.
CLICK HERE to Download
Wednesday, 23 July 2014
Monday, 21 July 2014
Write a program to generate a following numbers triangle.
(Where user entered number through keyboard, for example if num=5)
54321
4321
321
21
1
Ans.
/*c program for number triangle pyramid*/
#include<stdio.h>
#include<conio.h>
int main()
{
int num,c;
printf("Enter loop repeat number(rows): ");
scanf("%d",&num);
for(; num>=1; num--)
{
for(c=num; c>=1; c--)
printf("%d",c);
printf("\n");
}
getch();
getch();
return 0;
}
/*************OUTPUT****************
Enter loop repeat number(rows): 5
************************************/
/*************OUTPUT****************
Enter loop repeat number(rows): 5
54321
4321
321
21
1
************************************/
Write a program to generate a following numbers triangle:
(Where user entered number through keyboard, for example if num=5).
| 1 | ||||
| 1 | 2 | |||
| 1 | 2 | 3 | ||
| 1 | 2 | 3 | 4 | |
| 1 | 2 | 3 | 4 | 5 |
Ans.
/*c program for number triangle pyramid*/
#include<stdio.h>
#include<conio.h>
int main()
{
int num,r,c,sp;
printf("Enter loop repeat number(rows): ");
scanf("%d",&num);
for(r=1; num>=r; r++)
for(r=1; num>=r; r++)
{
for(sp=num-r; sp>=1; sp--)
printf(" ");
for(c=1; c<=r; c++)
printf("%d",c);
printf("\n");
}
getch();
getch();
return 0;
}
/*************OUTPUT****************
Enter loop repeat number(rows): 5
************************************/
/*************OUTPUT****************
Enter loop repeat number(rows): 5
| 1 | ||||
| 1 | 2 | |||
| 1 | 2 | 3 | ||
| 1 | 2 | 3 | 4 | |
| 1 | 2 | 3 | 4 | 5 |
************************************/
Write a program to generate a following numbers triangle:
Where user entered number through keyboard, for example if num=5)
12345
1234
123
12
1
Ans.
/*c program for number triangle pyramid*/
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
int main()
{
int num,c;
printf("Enter loop repeat number(rows): ");
scanf("%d",&num);
for(; num>=1; num--)
{
for(c=1; c<=num; c++)
printf("%d",c);
printf("\n");
}
return 0;
}
/*************OUTPUT****************
Enter loop repeat number(rows): 5
*********************************/
/*************OUTPUT****************
Enter loop repeat number(rows): 5
12345
1234
123
12
1
*********************************/
Write a program to generate a following numbers triangle:
(Where user entered number through keyboard, for example if num=5)
1
12
123
1234
12345
Ans.
/* c program for number triangle*/
#include<stdio.h>
//#include<conio.h>
int main()
{
int num,r,c;
printf("Enter loop repeat number(rows): ");
scanf("%d",&num);
for(r=1; r<=num; r++)
for(r=1; r<=num; r++)
{
for(c=1; c<=r; c++)
printf("%d",c);
printf("\n");
}
//getch();
return 0;
//getch();
return 0;
}
/*************OUTPUT**************
Enter loop repeat number(rows): 5
***********************************/
/*************OUTPUT**************
Enter loop repeat number(rows): 5
1
12
123
1234
12345
***********************************/
Subscribe to:
Posts (Atom)












