0% found this document useful (0 votes)
59 views21 pages

Su Dip Kumar

This document contains 15 C++ programs written by Sudip Kumar Mandal, a class 11 student at St. Xavier's High School in Bankura. The programs include functions to print text, calculate prime numbers, swap values, reverse numbers, check vowels/evens/odds/primes, and calculate student grades. All programs utilize standard C++ libraries and functions like cout, cin, getch(), and loops to demonstrate basic programming concepts.

Uploaded by

Sudip Kumar
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)
59 views21 pages

Su Dip Kumar

This document contains 15 C++ programs written by Sudip Kumar Mandal, a class 11 student at St. Xavier's High School in Bankura. The programs include functions to print text, calculate prime numbers, swap values, reverse numbers, check vowels/evens/odds/primes, and calculate student grades. All programs utilize standard C++ libraries and functions like cout, cin, getch(), and loops to demonstrate basic programming concepts.

Uploaded by

Sudip Kumar
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/ 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