Computer Science Project File Class 11

16
COMPUTER SCIENCE Project File NAME: PIYUSH SHARMA CLASS: XI A

description

Computer Science Project for class 11

Transcript of Computer Science Project File Class 11

Page 1: Computer Science Project File Class 11

COMPUTER SCIENCE Project File

NAME: PIYUSH SHARMACLASS: XI A

Page 2: Computer Science Project File Class 11

ROLL No: 38WAP TO CHECK WHETHER AN INPUT IS A CHARACTER OR A DIGIT

#include <iostream.h>int main(){ char ch; cout<<"Enter a character :"; cin>>ch; if (((ch>='A')&&(ch<='Z'))||((ch>='a')&&(ch<='z'))) cout<<"You entered an alphabet"<<"\n"; else if((ch>='0')&&(ch<='9')) cout<<"You entered a digit"<<"\n"; else cout<<"You entered a character other than"<<"\n"<<" Alpahbets or Digits"; return 0;}

Page 3: Computer Science Project File Class 11

WAP TO PRINT AREA OF A CIRCLE WITH A GIVEN RADIUS

#include <iostream.h>int main(){ int a; cout<<"Enter Radius Of Circle :"; cin>>a; float radius = a; float area; area = 3.14159*radius*radius; cout<<"Area of the circle is :"<<area; return 0;}

Page 4: Computer Science Project File Class 11

WAP TO PRINT ASCII CODE FOR A CHARACTER

#include <iostream.h>int main (){ char ch; cout<<"Enter Alphabet "; cin>>ch; int num=ch; cout<<"The ASCII code for "<<ch<<" is "<<num<<"\n"; cout<<"Adding 1 to the character code\n"; ch=ch+1; num=ch; cout<<"The ASCII code for "<<ch<<" is "<<num<<"\n"; return 0;}

Page 5: Computer Science Project File Class 11

WAP TO PRINT THE CUBE OF A NUMBER (USING FUNCTIONS)

#include<iostream.h>float cube(float);int main(){ float num; cout<<"Enter a number "; cin>>num; cout<<"\n"<<"The cube of "<<num<<" is "<<cube(num)<<"\n"; return 0;}float cube(float a){ return a*a*a;}

Page 6: Computer Science Project File Class 11

WAP TO CONVERT NUMBER OF DAYS INTO YEARS AND DAYS

#include<iostream.h>int main(){ int a; float y,w; cout<<"Enter number of days "; cin>>a; y=a/365; w=a/7; cout<<"Number Of Years in "<<a<<" Days are "<<y<<"\n"; cout<<"Number Of Weeks in "<<a<<" Days are "<<w; return 0;}

Page 7: Computer Science Project File Class 11

WAP TO TELL THE NTH TERM OF THE FIBONACCI SERIES

#include<iostream.h>#include<conio.h>void main(){clrscr();int a, next, first=0, second=1, n;cout<<"Enter the term of Fibonacci series:";cin>>n;cout<<"\n"<<"The "<<n<<" terms of series are:";for (a=0; a<n; a++){if (a<=1)next=a;else{next=first+second; first=second; second=next;}}cout<<next;}

Page 8: Computer Science Project File Class 11

WAP TO PERFORM FOUR BASIC OPERATIONS ON TWO NUMBERS

#include<iostream.h>int main(){ int a,b; cout<<"enter 2 numbers"; cin>>a>>b; cout<<"addition = "<<a+b<<"\n"; cout<<"subtraction = "<<a-b<<"\n"; cout<<"multiplication = "<<a*b<<"\n"; cout<<"division = "<<a/b<<"\n"; return 0;}

Page 9: Computer Science Project File Class 11

WAP TO TELL THE LARGEST NUMBER AMONG THREE NUMBERS

#include <iostream.h>int main(){ int a, b, c, max; cout<<"Enter three numbers :"; cin>>a>>b>>c; max=a; if(b>max) max=b; if(c>max) max=c; cout<<"\n"<<"The largest of "<<a<<", "<<b<<", "<<c<<" is "<<max; return 0;}

Page 10: Computer Science Project File Class 11

WAP TO MAKE A CALCULATOR ON FOUR BASIC OPERATIONS

#include <iostream.h>int main(){ char ch; float a, b, result; cout<<"Enter two numbers :"<<"\n"; cin>>a>>b; cout<<"Enter the operator (+, -. *, /):"<<"\n"; cin>>ch; if(ch=='+') result=a+b; else if(ch=='-') result=a-b; else

Page 11: Computer Science Project File Class 11

if(ch=='*') result=a*b; else if(ch=='/') result=a/b; else cout<<"Wrong Operator"; cout<<"The calculated result is: "<<result<<"\n"; return 0;

WAP TO TELL THE DAY OF THE WEEK FOR A GIVEN NUMBER

#include <iostream.h>int main(){ int a; cout<<"Enter a number (1-7)"<<"\n"; cin>>a; switch (a) { case 1: cout<<"Monday"; break; case 2: cout<<"Tuesday"; break; case 3: cout<<"Wednesday"; break; case 4: cout<<"Thursday"; break; case 5: cout<<"Friday";

Page 12: Computer Science Project File Class 11

break; case 6: cout<<"Saturday"; break; case 7: cout<<"Sunday"; break; } return 0;}

WAP TO PRINT THE SQUARE OF A NUMBER

#include<iostream.h>int main (){ int a; cout<<" enter the number "; cin>>a; if(a<120) { cout<<" square ="<<a*a; } else { cout<<" square is not allowed"; } return 0;}

Page 13: Computer Science Project File Class 11

WAP TO CONVERT TEMPERATURE ON USER’S CHOICE

#include <iostream.h>int main(){ int choice; double temp, conv_temp; cout<<"Temperature Conversion Menu"<<"\n"; cout<<"1.Fahrenheit to Celsius"<<"\n"; cout<<"2.Celsius to Fahrenheit "<<"\n"; cout<<"3.Kelvin to Celsius"<<"\n"; cout<<"4.Celsius to Kelvin"<<"\n"; cout<<"5.Kelvin to Fahrenheit"<<"\n"; cout<<"6.Fahrenheit to Kelvin"<<"\n"; cin>>choice; if(choice==1) { cout<<"\n"<<"Enter Temperature in Fahrenheit :"; cin>>temp;

Page 14: Computer Science Project File Class 11

conv_temp=(temp-32)/1.8; } if(choice==2) { cout<<"\n"<<"Enter Temperature in Celsius :"; cin>>temp; conv_temp=(1.8*temp)+32; } if(choice==3) { cout<<"\n"<<"Enter Temperature in Kelvin :"; cin>>temp; conv_temp=temp-273; } if(choice==4) { cout<<"\n"<<"Enter Temperature in Celsius :"; cin>>temp; conv_temp=temp+273; } if(choice==5) { cout<<"\n"<<"Enter Temperature in Kelvin :"; cin>>temp; conv_temp=(temp-459.67)*(5/9); } if(choice==6) { cout<<"\n"<<"Enter Temperature in Fahrenheit :"; cin>>temp; conv_temp=(9/5)*(temp-273)+32; } cout<<"The Temperature conversion is "<<conv_temp<<"\n"; return 0;}

Page 15: Computer Science Project File Class 11