0% found this document useful (0 votes)
25 views15 pages

Prime Number 100-200

The document contains code snippets in C++ demonstrating the use of for loops, while loops, and switch statements to output prime numbers between 100-200, letters A-Z corresponding to numbers 1-26, days of the week and months corresponding to numbers, patterns of numbers and stars, and calculating the sum of numbers from 1 to 100.

Uploaded by

John Yohans
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views15 pages

Prime Number 100-200

The document contains code snippets in C++ demonstrating the use of for loops, while loops, and switch statements to output prime numbers between 100-200, letters A-Z corresponding to numbers 1-26, days of the week and months corresponding to numbers, patterns of numbers and stars, and calculating the sum of numbers from 1 to 100.

Uploaded by

John Yohans
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Prime number 100-200

#include <stdio.h>

int main()

int i, Number, count;

printf(" Prime Number from 100 to 200 are: \n");

for(Number = 100; Number <= 200; Number++)

count = 0;

for (i = 2; i<= Number/2; i++)

if(Number%i == 0)

count++;

break;

if(count == 0 && Number != 1 )

printf(" %d ", Number);

return 0;

}
Alphabet

#include<iostream>

using namespace std;

int main()

int no;

cout<<"Enter any number and Desplay A-Z\n";

cin>>no;

switch(no)

case 1:

cout<<"A";

break;

case 2:

cout<<"B";

break;

case 3:

cout<<"C";

break;

case 4:

cout<<"D";

break;

case 5:

cout<<"E";

break;
case 6:

cout<<"F";

break;

case 7:

cout<<"G";

break;

case 8:

cout<<"H";

break;

case 9:

cout<<"I";

break;

case 10:

cout<<"J";

break;

case 11:

cout<<"K";

break;

case 12:

cout<<"L";

break;

case 13:

cout<<"M";

break;

case 14:
cout<<"N";

break;

case 15:

cout<<"O";

break;

case 16:

cout<<"P";

break;

case 17:

cout<<"Q";

break;

case 18:

cout<<"R";

break;

case 19:

cout<<"DS";

break;

case 20:

cout<<"T";

break;

case 21:

cout<<"U";

break;

case 22:

cout<<"V";
break;

case 23:

cout<<"W";

break;

case 24:

cout<<"X";

break;

case 25:

cout<<"Y";

break;

case 26:

cout<<"Z";

break;

default:

cout<<"Invalid input";

Date
#include<iostream>

using namespace std;

int main()

int no;

cout<<"Enter any number\n";

cin>>no;
switch(no)

case 1:

cout<<"Monday";

break;

case 2:

cout<<"Tuesday";

break;

case 3:

cout<<"Wednesday";

break;

case 4:

cout<<"Thrusday";

break;

case 5:

cout<<"Friday";

break;

case 6:

cout<<"Saturday";

break;

case 7:

cout<<"Sunday";

break;

default:

cout<<"Invalid input";
}

Month
#include<iostream>

using namespace std;

int main()

int no;

cout<<"Enter any number\n";

cin>>no;

switch(no)

case 1:

cout<<"meskerem";

break;

case 2:

cout<<"tikimt";

break;

case 3:

cout<<"hidar";

break;

case 4:

cout<<"tahisa";

break;

case 5:
cout<<"tir";

break;

case 6:

cout<<"yekatit";

break;

case 7:

cout<<"megabit";

break;

case 8:

cout<<"meyaziya";

break;

case 9:

cout<<"gimbot";

break;

case 10:

cout<<"sene";

break;

case 11:

cout<<"hamile";

break;

case 12:

cout<<"nehase";

break;

case 13:

cout<<"pagume";
break;

default:

cout<<"Invalid input";

return 0;

For loop

// to display a number from 10-1

#include <iostream>

using namespace std;

int main()

for(inti=10;i>=1; i--)

cout<<i<<endl;

return 0;

By star

#include <iostream>

using namespace std;

int main()
{

int n, i, j;

cout<< "Enter number of rows: ";

cin>> n;

for(i = 1; i<= n; i++)

//print * equal to row number

for(j = 1; j <= i; j++)

cout<< "* ";

cout<< "\n";

return 0;

To display a number from 10-1

#include <iostream>

using namespace std;

int main()
{

for(inti=10; i>=1; i--)

cout<<i<<""<<endl;

return 0;

To add a number from 1-100

#include <iostream>

using namespace std;

int main()

int sum=0;

for (inti=1; i<= 100;i++) {

sum = sum+i;

cout<< "\n The sum of numbers from 1 to 100 is: "<<sum <<endl;

return 0;

#include <iostream>

using namespace std;


int main()

inti = 1, sum=0;

while (i<= 100) {

sum = sum+i;

i++;

cout<< "\n The sum of numbers from 1 to 100 is: "<<sum <<endl;

return 0;

22

333

4444

55555

// to display

#include <iostream>

using namespace std;


int main()

for(inti=1;i<=5;i++)

for(int j=1;j<=i;j++)

cout<<i<<" ";

cout<<endl;

return 0;

555555

444444

333333

222222

111111

// to display

#include <iostream>

using namespace std;


int main()

for(int j=5;j>=1;j--)

for(int i=5;i>=1;i--)

cout<<j<<" ";

cout<<endl;

return 0;

54

543

5432

54321

// to display

#include <iostream>

using namespace std;


int main()

for(inti=5;i>=1;i--)

for(int j=5;j>=i;j--)

cout<<j<<" ";

cout<<endl;

return 0;

You might also like