Thursday, March 7, 2013

Write a program in C to print following pattern or triangle

Write a program in C to print following pattern or triangle
*
**
***
****
*****
******
*******

Solution:
/*Write a program in C to print following pattern or triangle*/
#include<stdio.h>
#include<conio.h>
main()
{
int n;
clrscr();
printf("Enter number of Rows\t");
scanf("%d",&n);
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
printf("*");}
printf("\n");}
getch();
}

Output: Enter number of Rows      7
*
**
***
****
*****
******
*******
                                                               For Download Click below

Sunday, March 3, 2013

Develop and initialize the given array in a C program that asks User to Enter an integer number for searching. The program witl check the entered number is prsesent in the array or not

Develop and initialize the given array in a C program that asks User to Enter an integer number for searching. The program witl check the entered number is prsesent in the arra or not
                          | 13 | 37 | 52 | 60 | 10 |12 | 15 | 18 | 42 | 25 | 30 | 48 | 20 |

Solution:
/*Develop and initialize the given array in a C program that asks User to Enter an integer number for searching. The program witl check the entered number is prsesent in the arra or not*/
#include<stdio.h>
#include<conio.h>
main()
{
int num[12]={13,37,52,10,12,15,18,42,25,30,48,20},n;
clrscr();
printf("Enter any integer\t");
scanf("%d",&n);
if(n==num[n])
{
printf("\nNumber is present");
}
else
printf("\n Number is not prsent");
getch();
}

                                    For Download Click below

Array