You are on page 1of 9

# NAME :ROLL NO.

:COURSE :-

i++) { if(str[i]!=str[len-i])//checking last and first element and then subtraction of both { cout<<"Not Palndrome"<<endl.i<=len. is palindrome or not class palindrome { public: palindrome(){} ~palindrome(){} void isPalindrome ()//function to check palindrome { char str[100]={}.// we are trying to get the middle element of array starting at zero for(int i=0. } OUTPUT:- . } }.isPalindrome(). Write a program to check whether a no. } } cout<<"Is Palndrome<<endl". cout<<"Enter String=>". return 0.#include "iostream" #include "cstring" using namespace std. len=strlen(str)-1.PROGRAM NO. int main() { palindrome p. p. int len=0. cin>>str. return .

} else { for(int j=2. class prime { public: prime(){} ~prime(){} void isPrime() { for(int i=1. } else if(i==j+1) { cout<<i<<" is prime"<<endl. } . #include "iostream" #include "cstring" using namespace std.Program to check whether a no.i<=50. break.j<i. is prime or not and print all prime nos. p.j++)/*rest all numberss are checked for remainder starting from 2 upto n-1*/ { if(i%j==0) { cout<<i<<" is not prime"<<endl.i++)//looping from 1 to 50 { OUTPUT:- if(i<4)//1-3 are prime by default { cout<<i<<" is prime"<<endl. from 1 to 50.PROGRAM NO.isPrime(). } } } } }. } int main() { prime p. return 0.

Program to print first n terms of fibonacci series int main() { int first=0. cout<<first<<" "<<second. for(i=3. } getch(). cout<<"How many nos. } OUTPUT:- PROGRAM NO. cout<<" "<<third.third.n. do you want to print?"<<endl. second=third.second=1.Program to take a date from user and tell how many days have passed till that date since the beginning of that year #include<iostream> .#include<iostream> #include<conio.PROGRAM NO.i++) { third=first+second. first=second.i.i<=n. cin>>n.h> using namespace std.

&dt.m) { case 12: days+=30. case 11: days+=31. }dt.y<<" are "<<dt.h> using namespace std. } inline int leap(int y) { if(y%4==0 || y%100==0) return 1.y).y.&dt.e. return 0. case 5: days+=30. case 6: days+=31. cout<<dt.#include<stdio. inline int leap(int).&dt. } /* in case of January there is no month before that hence only date of January will be added */ cout<<"The total days elapsed since January 1. case 10: days+=30.h> #include<conio. scanf("%2d/%2d/%4d". int main() { int days=0. case 9: days+=31. getch(). cout<<"Enter date (dd/mm/yyyy) i. switch(dt. case 4: days+=31. } OUTPUT:- .m. case 2: days+=31. case 3: days+=28. ". struct date { int d.d. case 8: days+=31.d + leap(dt. case 7: days+=30.m. return 0. 01/02/2012 "<<endl.m.y) + days.

int flag=0.#include <iostream> #include<conio.PROGRAM NO.h> using namespace std. . class time1 { Program to add two times with the help of classes.

if (min>60) { hour++.min. } void addtime1(time1 t1.min+t2. cin>>hour. sec=sec-60. min=min-60. } min=min + t1. min(0).int s) { hour=h. } hour=hour+ t1.sec. if (hour>=12) { hour=hour-12. else if(flag==1) cout<<hour<<":"<<min<<":"<<sec<<" pm".sec+t2. cin>>min. public: time1(): hour(0).private: int hour. cin>>sec. flag=1. sec=s.min.time1 t2) { sec=t1. int main() . } }. min=m. } void gettime1() { cout<<"Enter time1:.hour + t2.hour. sec(0) { } time1(int h.". } } void showtime1() { if (flag==0) cout<<hour<<":"<<min<<":"<<sec<<" am".int m.sec. if(sec>=60) { min++.

gettime1(). tm3.tm2). return 0. tm2.showtime1().6.addtime1(tm1. tm3. getch(). } OUTPUT:- . time1 tm1(5.{ time1 tm2.tm3.20).

switch(a) { case 1 :cout<<"enter the temperature in Celsius : ". int a.h> using namespace std.ft. cin>>a. cin>>ch. cout<<"temp in Celsius : "<<ct. cin>>ft.ch=1. int main() { float ct. } OUTPUT:- . } getch(). cout<<"temp in Fahrenheit : "<<ft. return 0.PROGRAM NO. ft=9*ct/5+32.Program to convert temperature given in Fahrenheit to Celsius and Celsius to Fahrenheit #include<iostream> #include<conio. ct=(ft-32)*5/9. case 2:cout<<"enter the temperature in Fahrenheit : ". } cout<<endl<<"do you want to continue (press 1 for yes and 2 for no) : ". while(ch==1) { cout<<"press 1 to convert Celsius to Fahrenheit "<<endl. cin>>ct. break. break. cout<<"2 to convert Fahrenheit to Celsius"<<endl<<"enter choice : ".