1.Write a program to display 1 up to l0 horizontally(i.e separated by tab \t as well as vertically use the end line \n or endl.
2.Write a program is to find the factorial of 10!.
3. Write a program to display the reverse of a given number for example if a user enters 123 the program should display 321.
4. Develop C++ program which works class time schedule of yours?
/*
*C++ Program to 1-10 horizontally separated by tab and vertically separated by new line/endl
*/
#include <iostream>
using namespace std;
int main()
{
//Horizontal display
for(int i = 1; i <= 10; i++)
{
cout<<i<<"\t";
}
//Add two blank lines
cout<<"\n \n";
//Vertical display
for(int j = 1; j <= 10; j++)
{
cout<<j<<"\n";
}
return 0;
}
/*
C++ program to find the factorial of 10
*/
#include<iostream>
using namespace std;
int main()
{
int factorial=1;
for (int i=1; i<= 10; i++) {
factorial=factorial*i;
}
cout<<"Factorial of 10 is:"<<factorial<<endl;
return 0;
}
/*
*C++ Program to display a given number in reverse oder
*/
#include <iostream>
using namespace std;
int main()
{
int number; //The user given number
int reversedNum =0;
int remainder;
cout<<"Enter a number to display in reverse order: ";
cin>>number;
while(number!=0)
{
remainder=number%10;
reversedNum=reversedNum*10+remainder;
number /= 10;
}
cout<<number <<"In reversed order is: "<<reversedNum<<endl;
return 0;
}
/*
*C++ Program to work class time
*/
#include <iostream>
using namespace std;
int main()
{
cout<<"Monday Class Schedule"<<endl;
cout<<"8.00oam-10.00am Algebra"<<endl;
cout<<"10.00am-11.00am Break"<<endl;
cout<<"11.00aam-1.00pm Programming"<<endl;
cout<<"1.00pm-2.00pm Lunch Break"<<endl;
cout<<"3.00pm-5.00pm Statistics"<<endl;
return 0;
}
Comments
Leave a comment