1: //*****
2: // ****
3: // ***
4: // **
5: // *
6: #include<stdio.h>
7: #include<conio.h>
8: void main()
9: {
10: int i, j, k, row;
11: clrscr();
12: printf("Enter the number of rows you want:\n");
13: scanf("%d",&row);
14: for(i=row;i>=1;i--)
15: {
16: for(j=row;j>i;j--)
17: {
18: printf(" ");
19: }
20: for(k=1;k<=i;k++)
21: {
22: printf("*");
23: }
24: printf("\n");
25: }
26: getch();
27: }
getsprogramming Tutorials , C Programming, CPP Programming and JAVA Programming , Python Programming , Javascript Programming Welcome to getsprogramming Blog Here You Find Different Programs in Easier way to Explain and gain Knowledge and Try Your Self..Thanks
Friday, 9 October 2015
Write a C Program To Print Pattern4
Write a C Program To Print Following Pattern
1: // WAP to print following pattern
2: //*****
3: //****
4: //***
5: //**
6: //*
7: #include<stdio.h>
8: #include<conio.h>
9: void main()
10: {
11: int row,i,j;
12: clrscr();
13: printf("Enter the number of rows you want: \n");
14: scanf("%d",&row);
15: for(i=row;i>=1;i--)
16: {
17: for(j=1;j<=i;j++)
18: {
19: printf("* ");
20: }
21: printf("\n");
22: }
23: getch();
24: }
Write a C Program To Print Pattern
1: // *
2: // **
3: // ***
4: // ****
5: //*****
6: #include<stdio.h>
7: #include<conio.h>
8: void main()
9: {
10: int i, j, k, row;
11: clrscr();
12: printf("Enter the number of rows you want:\n");
13: scanf("%d",&row);
14: for(i=row;i>=1;i--)
15: {
16: for(j=1;j<i;j++)
17: {
18: printf(" ");
19: }
20: for(k=row;k>=i;k--)
21: {
22: printf("*");
23: }
24: printf("\n");
25: }
26: getch();
27: }
Write a C Program To Print Triangle Pattern
Output
1: //*
2: //**
3: //***
4: //****
5: //*****
6: #include<stdio.h>
7: #include<conio.h>
8: void main()
9: {
10: int row,i,j;
11: clrscr();
12: printf("Enter the number of rows you want: \n");
13: scanf("%d",&row);
14: for(i=1;i<=row;i++)
15: {
16: for(j=1;j<=i;j++)
17: {
18: printf("* ");
19: }
20: printf("\n");
21: }
22: getch();
23: }
Wednesday, 7 October 2015
Write a CPP Program To Perform Contructor And Destructor
Write a CPP Program To Perform Contructor And Destructor
1: #include<iostream.h>
2: #include<stdio.h>
3: class sum
4: {
5: int a,b;
6: public:
7: sum()
8: {
9: cout<< "Enter 2 numbers" << endl;
10: cin>>a>>b;
11: cout<< "Sum = "<<a+b;
12: }
13: ~sum()
14: {
15: cout<< "\nDestructor invoked"<<endl;
16: }
17: };
18: int main()
19: {
20: sum t;
21: }
Write a CPP Program To Check Number is Armstrong or Not
Write a CPP Program To Check Number is Armstrong or Not
1: #include<iostream.h>
2: #include<stdio.h>
3: int main()
4: {
5: int num,rem,c,result=0;
6: cout<< "Enter number" <<endl;
7: cin>>num;
8: c=num;
9: do
10: {
11: rem=num%10;
12: result=result+(rem*rem*rem);
13: num=num/10;
14: }
15: while(num>0);
16: if(result==c)
17: cout<< "Armstrong"<<endl;
18: else
19: cout<< "Not armstrong"<<endl;
20: }
Write a CPP Program To Swap Two Numbers
Write a CPP Program To Swap Two Numbers
1: #include<iostream.h>
2: #include<stdio.h>
3: int main()
4: {
5: int a,b,c;
6: cout << "Enter 2 numbers" << endl;
7: cin>>a>>b;
8: cout<< "Initially"<<endl;
9: cout<< "a = "<<a<<endl;;
10: cout<< "b = "<<b<<endl;
11: c=a;
12: a=b;
13: b=c;
14: cout<< "Swapped"<<endl;
15: cout<< "a = "<<a<<endl;;
16: cout<< "b = "<<b<<endl;
17: }
Write a CPP Program To Find Inputed Number is Positive Or Not
Write a CPP Program To Find Inputed Number is Positive Or Not
1: #include<iostream.h>
2: #include<stdio.h>
3: int main()
4: {
5: int a;
6: cout << "Enter a number" << endl;
7: cin>>a;
8: if (a>=0)
9: cout << "Positive : " << a<<endl;
10: else
11: cout << "Negative : " << -a<<endl;
12: }
Write a CPP Program To Find Remainder Of Input Number
Write a CPP Program To Find Remainder Of Input Number
1: #include<iostream.h>
2: #include<stdio.h>
3: int main()
4: {
5: int n,rem;
6: cout<< "Enter number"<<endl;
7: cin>>n;
8: for(;n>0;n=n/10)
9: {
10: rem=n%10;
11: cout<< rem;
12: }
13: }
Write a CPP Program To Find Factorial Of Input Number
Write a CPP Program To Find Factorial Of Input Number
1: #include<iostream.h>
2: #include<stdio.h>
3: int main()
4: {
5: int n,fact=1;
6: cout<< "Enter number"<<endl;
7: cin>>n;
8: for(;n>0;n--)
9: {
10: fact=fact*n;
11: }
12: cout<< "Factorial = "<<fact<<endl;
13: }
Subscribe to:
Posts (Atom)