0% found this document useful (0 votes)
67 views16 pages

Su Dip Kumar Man Dal

This document contains C++ code for 10 different programs: 1) Display a sentence, 2) Print prime numbers, 3) Swap two numbers, 4) Print a string, 5) Print a table of numbers, 6) Print a star pyramid, 7) Reverse a number, 8) Find the largest of two numbers, 9) Check if a character is a vowel, and 10) Calculate the grade of a student based on their marks in 5 subjects. Each program contains the necessary #include statements and uses functions like cout, cin, and getch() to take input, display output, and pause the program.

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)
67 views16 pages

Su Dip Kumar Man Dal

This document contains C++ code for 10 different programs: 1) Display a sentence, 2) Print prime numbers, 3) Swap two numbers, 4) Print a string, 5) Print a table of numbers, 6) Print a star pyramid, 7) Reverse a number, 8) Find the largest of two numbers, 9) Check if a character is a vowel, and 10) Calculate the grade of a student based on their marks in 5 subjects. Each program contains the necessary #include statements and uses functions like cout, cin, and getch() to take input, display output, and pause the program.

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/ 16

St.

Xavier's High School


Bankura

Computer project

Name- Sudip Kumar Mandal

Class- XI

Roll no.- 31

Subject- Computer
To display a sentence

#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;

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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy