0% found this document useful (0 votes)
10 views20 pages

PPS Cse

The document is a practical file for a programming course in the Department of Computer Science and Engineering at RIMT University. It contains a series of C++ programs that demonstrate basic programming concepts such as input/output, arithmetic operations, control structures, and functions. The programs include examples for printing messages, performing calculations, checking even/odd numbers, and calculating factorials.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views20 pages

PPS Cse

The document is a practical file for a programming course in the Department of Computer Science and Engineering at RIMT University. It contains a series of C++ programs that demonstrate basic programming concepts such as input/output, arithmetic operations, control structures, and functions. The programs include examples for printing messages, performing calculations, checking even/odd numbers, and calculating factorials.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

PRACTICAL FILE

PROGRAMMING FOR PROBLEM SOLVING

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBMITTED BY: SUBMITTED TO:

AMARJIT KUMAR MRS: SUKHPREET KAUR

24BCSE003 ASSISTANT PROFESSOR

CSE DEPT

SCHOOL OF ENGINEERING

RIMT UNIVERSITY, MANDI GOBINDGARH, PUNJAB


JANUARY 2025 - MAY 2025
PROGRAM 1: WAP TO PRINT OUT “HELLO WORLD”.
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

cout<<”Hello,World”;

getch();

}
PROGRAM 2 : WAP TO DISPLAY THE SIZE OF CHAR,INT,FLOAT AND DOUBLE
(in btyes).
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

cout<<”size of char : “<<sizeof(char)<<”byte”<<endl;

cout<<size of int : “<<sizeof(int)<<”byte”<<endl;

cout<<size of float : “<<sizeof(float)<<”byte”<<endl;

cout<<size of double : “<<sizeof(double)<<”byte”<<endl;

Getch();

}
PROGRAM 3; WAP FOR THE ADDITION OF TWO NUMBERS.
#include<iostream.h>

#include<conio.h>

void main()

int a,b,c;

clcscr()

cout<<”Enter Two Numbers : ”;

cin>>a>>b;

c=a+b;

cout<<”\nAddition =”<<c;

getch();

}
PROGRAM 4: WAP FOR THE SUBTRACTION OF TWO NUMBERS.
#include<iostream.h>

#include<conio.h>

void main()

int a,b,c;

clcscr()

cout<<”Enter Two Numbers : ”;

cin>>a>>b;

c=a+b;

cout<<”\nSubtraction=”<<c;

getch(); }
PROGRAM 5 : WAP FOR THE DIVISION OF TWO NUMBERS.
#include<iostream.h>

#include<conio.h>

void main()

float a,b,c;

clcscr()

cout<<”Enter Two Numbers : ”;

cin>>a>>b;

if(b!=0){

c=a/b;

cout<<”\nDivision =”<<c;

else {

cout<<”\nError:Division by zero is not allowed.”;

Getch()

}
PROGRAM 6: WAP TO SWAP ANY TWO RANDAM GIVEN NUMBER.
#include<iostream.h>

#include<conio.h>

void main()

clcscr()

int a.b;

cout<<”Enter Two Numbers : ”;

cin>>a>>b;

a=a+b;

b=a-b;

c=a-b;

cout<<”\nAfter swapping:”;

cout<<”\nFirst number =”<<a;

cout<<”\nSecond number =”<<b;

getch();

}
PROGRAM 7: WAP TO CHECK WHETHER A NUMBER IS EVEN OR ODD.
#include<iostream.h>

#include<conio.h>

void main()

clcscr()

int num;

cout<<”Insert any Two Numbers : ”;

cin>>num;

if(num%2=0)

cout<<”The number is even “;

}else

Cout<<”The number is odd”;

Getch(); }
Program 8 : PROGRAM TO SHOW THE USE OF ENDL.
#include<iostream.h>

#include<conio.h>

int main()

int a=100;

double b=3.14;

clrscr();

cout<<”a=”<<a;

cout<<endl;

cout<<”b=”<<endl<<”a*b=”<<a*b;

getch();

return 0;

}
Program 9 : PROGRAM TO SHOW THE USE OF ENDL.
#include<iostream.h>

#include<conio.h>

int main(){

int a,b;

clrscr();

a=10;

cout<<”a:”<<a;

b=4;

cout<<”\nb:”<<b;

a=b;

b=7;

cout<<\na:<<a;

cout<<\nb:<<b;

getch();

return 0;

}
Program 10: Program to show the significance of conditional operators.
#include<iostream.h>

#include<conio.h>

int main()

int a,b,c;

clrscr();

a=2;

b=7;

c=(a>b)?a:b;

cout<<c;

getch();

return 0;

}
Program 11: PROGRAM TO ENTER AN INTGERS AND FIND THE NUMBER IS EVEN OR ODD.
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

int x;

cout<<”enter an intgers : “;

cin>>x;

if(x%2==0)

cout<<”the number “<<x<<”is even “;

else

cout<<”the number “<<x<<”is odd”;

getch();

}
Program 12: PROGRAM TO PRINT THE FIBONACCI SERIES.
#include<iostream.h>

#include<conio.h>

void main()

clrscr();

int a,b,x,y,count,num;

a=0;

b=1;

cout<<”Enter the number of terms(less than 25);”<<endl;

cin>>num;

cout<<a<<”\t”;

cout<<b<<”\t”;

for(count=3;count<=num;count++)

{x=a+b;

Cout<<x<<’\t”;

a=b;

b=x;

getch();}
Program 13: PROGRAM TO SHOW THE IMPORTANCE OF CONTINUE STATEMENT.
#include<iostream.h>

#include<conio.h>

int x=0;

while(x<10)

++x;

if(x%2==0)

continue;

cout<<<x<<”is an odd number.”<<endl;

getch();

return 0;

}
Program 13 : PROGRAM TO ILLUSTRATE THE WORKING OF PASS BY VALUE.
#include<iostream.h>

#include<conic.h>

int add(int n);

int main(){

int number.result;

number=5;

cout<<”the initial value of number : “<<number<<endl;

result=add(number);

cout<<”the final value of number:”<<number<<endl;

cout<<”the result is :”<<result<<endl;

getch();

return 0;

int add(int number)

number=number+100;

return(number);

}
Program 14 : PROGRAM TO ILLUSTRATE THE WORKING OF PASS BY REFERENCE.
#include<iostream.h>

#include<conio.h>

void fun1(int&y)

cout<<”y=”<<y<<endl;

y=6;

cout<<”y=”<<y<<endl;

int main()

int x=5;

cout<<”x=”<<x<<endl;

fun1(x);

cout<<”x=”<<x<<endl;

getch();

return 0;

}
Program 15: PROGRAM TO SHOW THE AVERAGE AGE,MAXIMUM AGE AND MINIMUM AGE
OF THE STUDENT OF A CLASS.

#include<iostream.h>

#include<conio.h>

int main()

int age[10];

int i,sum=0,avg=0;

int max=0,min=100;

for(i=0;i<5;i++){

cout<<”Enter the age of the student”<<i+1<<emdl;

cin>>age[i];

if(age[i]>max)

max=age[i];}

if(age[i]>min)

{ min=age[i];

avg=sum/5;

cout<<”average age of the student of the class:”<<avg<<endl;

cout<<”maximum age of the student of the class:”<<max<<endl;

cout<<”minimum age of the student of the class:”<<min<<endl;

getch();

return(0);}
Program 16: PROGRAM TO FIND THE TOTAL DAYS IN THE YEAR TILL DATES.
#include<iostream.h>

#include<conio.h>

void main(){

clrscr();

int day,month,total;

int days_per_month[12]={31,28,31,30,31,30,31,31,30,31);

cout<<”Enter the month:”<<endl;

cin>>month;

cout<<’Enter the day:”<<endl;

cin>>day;

total=day;

for(int x=0;x<month-1;x++)

total+=days_per_month[x];

cout<<”The number of days in this year till date =”<<total<<endl;

getch();

}
Program :17 ; PROGRAM TO CALCULATE THE FACTORIAL OF A NUMBER WITH THE HELP OF
LOOP.

#include<iostream.h>

#include<conio.h>

int main()

int n,fact=1,i;

cout<<”Enter the number whose factorial has to be calculated”<<endl;

cin>>n;

if(n<=1)

fact=1;

else{

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

fact=fact*i;

cout<<”the factorial of “<<n<<”is”<<fact<<endl;

getch();

return(0);

You might also like