for loop program examples

Write a C++ Program to display Box shape using for loop.

Write a C++ Program to display Box shape using for loop.

Write a C++ Program to display Box shape using for loop Object: Write a C++ Program to display Box shape using for loop. C++ for loop Programs examples. Code: #include<iostream> #include<conio.h> using namespace std; const int width=40; const int height=20; void main() { int i; cout<<“\n\t\t*********************************************\n”; cout<<“\t\t\t: Display Box Shape:\n”; cout<<“\t\t*********************************************\n”; cout<<“\n\n\t\t”; for(int i=0;i<width-18;i++) { …

Write a C++ Program to display Box shape using for loop. Read More »

Snake game in C++

Snake game in C++

Write a Program Snake game in C++ Object: Write a Snake game Program in C++, C++ Projects. Code: #include<iostream> #include<conio.h> #include<windows.h> using namespace std; enum eDirection { STOP=0,LEFT,RIGHT,UP,DOWN}; eDirection dira; bool gameOver; void setup(); void Draw(); void Input(); void Logic(); void Logic2(); const int width=20; const int height=20; int x,y, fruitX, fruitY,score; int tailx[100],taily[100]; int …

Snake game in C++ Read More »

Program to find transpose of a matrix by using multi-dimensional arrays.

Program to find transpose of a matrix by using multi-dimensional arrays.

Find Transpose of a Matrix by Using Multi-dimensional Arrays Object: Write a C++ program to find transpose of a matrix by using multi-dimensional arrays. C++ Projects Code: #include<iostream> #include<conio.h> using namespace std; void main() { int mat[4][5],i,j; cout<<“Enter matrix values:\n”; for(i=0;i<4;i++) { for(j=0;j<5;j++) { cin>>mat[i][j]; } } cout<<endl; for(i=0;i<4;i++) { cout<<“[ “; for(j=0;j<5;j++) { cout<<mat[i][j]<<” …

Program to find transpose of a matrix by using multi-dimensional arrays. Read More »

Program Generate for loop, while loop, and do while loop using if and switch functions

Program Generate for loop, while loop, and do while loop using if and switch functions

Generate a Loops for loop, while loop, and do while loop using if and switch functions Objects: Write a program to generate a Loops for loop, while loop, and do while loop using if and switch functions. C++ Projects. Code: #include<iostream> #include<conio.h> #include<string> using namespace std; void main() { char a; int i=0,f1,id,no,tab; char whl,ch=0,dow; …

Program Generate for loop, while loop, and do while loop using if and switch functions Read More »

Write a program to calculate the factorial of any number

Write a program to calculate the factorial of any number

Calculate the Factorial Of Any Number Object: Write a program to calculate the factorial of any number. C++ Projects. Code: #include<iostream> #include<conio.h> using namespace std; void main() { int i,no,fact=1; cout<<” Enter Any Number: “; cin>>no; for(i=no;i>=1;i–) { fact=fact*i; } cout<<“\n Factorial of given Number is: “<<fact; getch(); } #include<iostream> #include<conio.h> using namespace std; void …

Write a program to calculate the factorial of any number Read More »

Write a program that generates a table of any number

Write a program that generates a table of any number

Program that generates a table of any number   Object: Write a program that generates a table of any number. C++ Projects. Code: #include<iostream> #include<conio.h> using namespace std; void main() { int no,i,tab; cout<<” :Table Generator:\n\n”; cout<<“Enter Any Number: “; cin>>no; for(i=1;i<=10;i++) { tab=no*i; cout<<no<<” * “<<i<<“= “<<tab<<endl; } getch(); } #include<iostream> #include<conio.h> using namespace …

Write a program that generates a table of any number Read More »