Learn C++ beginer programs

July 8, 2009

write a program to diaplay a pyramid as shown:

Filed under: cout,for loop,loop,pyramid — snehilkhanor @ 11:52 am
The following output is obtained:

    1
   212
  32123
 4321234
543212345
543212345
 4321234
  32123
   212
    1

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. for (int i=1;i<=5;i++)
  7. {
  8. for(int j=4;j>=i;j–)
  9. cout<<” “;
  10. for(int k=1;k<=i;k++)
  11. cout<<k;
  12. for(k=i-1;k>=1;k–)
  13. cout<<k;
  14. cout<<”\n”;
  15. }
  16. for (i=5;i>=1;i–)
  17. {
  18. for(int j=4;j>=i;j–)
  19. cout<<” “;
  20. for(int k=1;k<=i;k++)
  21. cout<<k;
  22. for(k=i-1;k>=1;k–)
  23. cout<<k;
  24. cout<<”\n”;
  25. }
  26. getch();
  27. }

write a program to diaplay a pyramid as shown:

Filed under: cout,for loop,loop,pyramid — snehilkhanor @ 5:32 am
Following output is displayed:

    1
   212
  32123
 4321234
543212345

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. for (int i=1;i<=5;i++)
  7. {
  8. for(int j=4;j>=i;j–)
  9. cout<<” “;
  10. for(int k=1;k<=i;k++)
  11. cout<<k;
  12. for(k=i-1;k>=1;k–)
  13. cout<<k;
  14. cout<<”\n”;
  15. }
  16. getch();
  17. }

write a program to diaplay a pyramid as shown:

Filed under: cout,for loop,loop,pyramid — snehilkhanor @ 5:23 am
The following output is displayed:

1
12
123
1234
12345

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. for (int i=1;i<=5;i++)
  7. {
  8. for(int j=1;j<=i;j++)
  9. cout<<j;
  10. cout<<”\n”;
  11. }
  12. getch();
  13. }

write a program to diaplay a pyramid as shown:

Filed under: cout,for loop,loop,pyramid — snehilkhanor @ 5:15 am
Following output is obtained:

****
***
**
*

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. for(int i=1;i<=4;i++)
  7. { for(int j=4;j>=i;j–)
  8. cout<<”*”;
  9. cout<<”\n”;
  10. }
  11. getch();
  12. }

write a program to diaplay a pyramid as shown:

Filed under: cout,for loop,loop,pyramid — snehilkhanor @ 5:09 am
Following output is obtained:

*
**
***
****

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. for(int i=1;i<=4;i++)
  7. { for(int j=1;j<=i;j++)
  8. cout<<”*”;
  9. cout<<”\n”;
  10. }
  11. getch();
  12. }

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.