Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

St.

Xavier's High School


Bankura

Computer project

Name- Sudip Kumar Mandal

Class- XI

Roll no.- 31

Subject- Computer
#include<iostream.h>

#include<conio.h>

void main()

clrscr(); // clear the screen

cout<<"Hello Compiler, I am C++";

getch(); // holds output screen until user press a key


Print Prime Number
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

int start, end, i, j, count=0;

// to print all the prime number between any range

// enter the two number (starting and ending)

cout<<"Enter starting number : ";

cin>>start;

cout<<"Enter ending number : ";

cin>>end;

cout<<"Prime Number Between "<<start<<" and "<<end<<" is :\n";

for(i=start; i<=end; i++)

count=0;

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

if(i%j==0)

count++;

break;

if(count==0)

cout<<i<<" ";

}
}

getch();
Swap Two Numbers
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num1, num2, swap;
cout<<"Enter two number : ";
cout<<"\nFirst Number : ";
cin>>num1;
cout<<"Second Number : ";
cin>>num2;
swap=num1;
num1=num2;
num2=swap;
cout<<"The value of first and second
number after swapping is \n";
cout<<"First Number =
"<<num1<<"\n"<<"Second Number =
"<<num2;
getch();
Print String
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char str[20];
cout<<"Enter your first name : ";
gets(str);
cout<<"Hello, "<<str;
getch();
Print Table of Number
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num, i, tab;
cout<<"Enter a number : ";
cin>>num;
cout<<"Table of "<<num<<" is \n\n";
for(i=1; i<=10; i++)
{
tab=num*i;
cout<<num<<" * "<<i<<" = "<<tab<<"\n";
}
getch();
Print star pyramid
#include <iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i, space, rows, k=0;
cout<<"Enter the number of rows : ";
cin>>rows;
for(i=1; i<=rows; i++)
{
for(space=1; space<=(rows-i); space++)
{
cout<<" ";
}
while(k!=(2*i-1))
{
cout<<"* ";
k++;
}
k=0;
cout<<"\n";
}
getch();
Reverse Number
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num, rev=0, rem;
cout<<"Enter a number : ";
cin>>num;
while(num!=0)
{
rem=num%10;
rev=rev*10+rem;
num=num/10;
}
cout<<"Reverse = "<<rev;
getch();
Find Largest of Two Number
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a, b, big;
cout<<"Enter two number : ";
cin>>a>>b;
if(a>b)
{
big=a;
}
else
{
big=b;
}
cout<<"Biggest of the two number is "<<big;
getch();
Check Vowel or Not
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
cout<<"Enter an alphabet : ";
cin>>ch;
if(ch=='a' || ch=='A' || ch=='e' || ch=='E' ||
ch=='i' || ch=='I' || ch=='o' || ch=='O' ||
ch=='u' || ch=='U')
{
cout<<"This is a vowel";
}
else
{
cout<<"This is not a vowel";
}
getch();
Check Even or Odd
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num;
cout<<"Enter a number :";
cin>>num;
if(num%2==0)
{
cout<<"This is an even number";
}
else
{
cout<<"This is an odd number";
}
getch();
Check Prime or Not
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,i,count=0;
cout<<"Enter a number:";
cin>>num;
for(i=2;i<num;i++)
{
if(num%i==0)
{
count++;
break;
}
}
if(count==0)
{
cout<<"This is a prime number";
}
else
{
cout<<"This is not a prime number";
}
getch();
Calculate Grade of Student
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int mark[5], i;
float sum=0,avg;
cout<<"Enter marks obtained in 5 subjects :";
for(i=0; i<5; i++)
{
cin>>mark[i];
sum=sum+mark[i];
}
avg=sum/5;
cout<<"Your Grade is ";
if(avg>80)
{
cout<<"A";
}
else if(avg>60 && avg<=80)
{
cout<<"B";
}
else if(avg>40 && avg<=60)
{
cout<<"C";
}
else
{
cout<<"D";
}
getch();

You might also like