SlideShare uma empresa Scribd logo
1 de 15
1. Write a program to accept three integers and print the largest of them?
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<“Enter three numbers ”;
cin>>a>>b>>c;
if(a>b && a>c)
cout<<a;
else if(b>a && b>c)
cout<<b;
else if(c>a && c>b)
cout<<c;
getch();
}
2. Write a program to input a character and check whether a given character is in alphabet or a
digit or any other special character.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char a;
cout<<“Enter a character ”;
cin>>a;
if(a>= && a<=)
cout<<“You have entered a lowercase alphabet”;
else if(a>= && a<= )
cout<<“You have entered an uppercase alphabet”;
else if(a>= && a<=)
cout<<“You have entered a digit”;
else
cout<<“You have entered a special character”;
getch();
}
3. Write a program to print first ten natural numbers and their sum.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b=0;
for(a=1;a<=10;a++)
{
cout<<a<<endl;
b+=a;
}
cout<<“Summation ”<<b;
getch();
}
4. Write a program to print the following series.
0 1 1 2 3 5 8 13
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
unsigned long first, second, third, n;
first=0;
second=1;
cout<<“How many elements you want to enter ”<<endl;
cin>>n;
cout<<first<<endl;
for(int i=2; i<n; i++)
{
third=first+second;
cout<<third;
first=second;
second=third;
}
getch();
}
5. Write a program to check whether a given number is palindrome or not.
#include<iostream.h>
#include<conio.h>
void main()
{
int n, num, digit, rev=0;
cout<<“Enter any number ”;
cin>>num;
n=num;
do
{
digit=num%10;
rev=(rev*10)+digit;
num=num/10;
}
while(num!=10)
cout<<“The reverse of the number is ”<<rev;
if(n==rev)
cout<<“The number is a Palindrome”;
else
cout<<“The number is not a Palindrome”;
getch();
}
6. Write a program to accept the marks of ten students and store them in an array. Also display the
total marks.
#include<iostream.h>
#include<conio.h>
void main()
{
int n, a[10], t=0;
for(n=1;n<=10;n++)
{
cout<<“Enter the marks of student ”<<n<<endl;
cin>>a[n];
t=t+a[n];
}
cout<<“The total of the marks is ”<<t;
getch();
}
7. Write a program to search for a specific element in a 1-D array through linear search.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[5], size, i, flag=0, num, pos;
cout<<“Enter the number of elements in an array ”;
cin>>size;
cout<<“Enter the elements of the array ”;
for(i=0;i<size;i++)
{
cin>>a[i];
}
cout<<“Enter the element to be searched ”;
cin>>num;
for(i=0;i<size;i++)
if(a[i]==num)
{
flag=1;
pos=i;
break;
}
if(flag==0)
{
cout<<“Element not found!”;
}
else
{
cout<<“Element found at position ”<<pos+1;
}
getch();
}
8. Write a program to find the number of vowels in a given line of text using an array.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
char line[100];
int vow=0;
cout<<“Enter a sentence ”<<endl;
gets(line) ;
for(int i=0 ; line[i] !=‘0’;i++)
{
switch(line[i])
{
case ‘a’;
case ‘A’;
case ‘e’;
case ‘E’;
case ‘I’;
case ‘I’;
case ‘o’;
case ‘O’;
case ‘u’;
case ‘U’;
vow++;
}
}
cout<<“Total number of vowels in the given line is ”<<vow;
getch();
}
9. An array emp[20] contains the number of employees joined in different years. Write a
program to find out the number of year in which no employee joined.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int emp[20], number_of_year=0;
cout<<“Enter the number of employees who joined in ”;
for(i=0;i<20;i++)
{
cout<<“Year is ”<<i+1<<endl;
cin>>emp[20];
if(emp[i]==0)
number_of_year=number_of_year+1;
}
cout<<“In ”<<number_of_year<<“ year number of employees joined”;
getch();
}
10. Write a program to calculate the length of string without using a library function.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char str[20];
int a;
for(a=1; a<=20;a++)
{
cin>>str[a];
}
cout<<“Length of string is ”<<a;
getch();
}
11. Write a program that checks whether the given character is alphanumeric or a digit by using
standard library function.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
char ch;
int a;
cout<<“Enter a character ”;
cin>>ch;
a=ch;
if(isalnum(a))
{
cout<<“Alphanumeric Character”;
}
else if(isalpha(a))
{
cout<<“Alphabetic Character”;
}
else if(isdigit(a))
{
cout<<“Numeric Character”;
}
else
cout<<“Other Character”;
getch();
}
12. Write a program to swap two values and make a new program.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
void swap(int &, int &)
int a, b;
cout<<“Enter the first number ”;
cin>>a;
cout<<“Enter the second number ”;
cin>>b;
swap(a, b);
cout<<“After swapping the values are ”<<a<<b;
getch();
}
void swap(int &x, int &y)
{
int z;
z=x;
x=y;
y=z;
cout<<“The swapped values are ”<<x<<y;
}
13. Write a program to generate the following output:
#include<iostream.h>
#include<conio.h>
void main()
{
int a, b;
for(a=1;a<=5;a++)
{
for(b=1;b<=a;b++)
{
cout<<“* ”;
}
cout<<endl;
}
getch();
}
*
* *
* * *
* * * *
* * * * *
14. Write a function that finds a sub-string from a given string and returns the string to its caller
function.
#include<iostream.h>
#include<conio.h>
void main()
{
15. Write a program that generates the following output:
#include<iostream.h>
#include<conio.h>
void main()
{
int a, b, c, d;
for(a=1;a<=4;a++)
{
for(b=1;b<=a;b++)
{
cout<<“* ”;
}
cout<<endl;
}
for(c=1;c<=3;c++)
{
for(d=3;d>=c;d‒‒)
{
cout<<“* ”;
}
cout<<endl;
}
getch();
}
*
* *
* * *
* * * *
* * *
* *
*

Mais conteúdo relacionado

Mais procurados

Oops practical file
Oops practical fileOops practical file
Oops practical file
Ankit Dixit
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 
1 borland c++ 5.02 by aramse
1   borland c++ 5.02 by aramse1   borland c++ 5.02 by aramse
1 borland c++ 5.02 by aramse
Aram SE
 
Computer Practical
Computer PracticalComputer Practical
Computer Practical
PLKFM
 

Mais procurados (20)

SaraPIC
SaraPICSaraPIC
SaraPIC
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
Let us c(by Yashwant Kanetkar) 5th edition solution chapter 1
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C++ 4
C++ 4C++ 4
C++ 4
 
week-6x
week-6xweek-6x
week-6x
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
1 borland c++ 5.02 by aramse
1   borland c++ 5.02 by aramse1   borland c++ 5.02 by aramse
1 borland c++ 5.02 by aramse
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 
Computer Practical
Computer PracticalComputer Practical
Computer Practical
 
Lab 1: Compiler Toolchain
Lab 1: Compiler ToolchainLab 1: Compiler Toolchain
Lab 1: Compiler Toolchain
 
C++ file
C++ fileC++ file
C++ file
 
Cmptr ass
Cmptr assCmptr ass
Cmptr ass
 
C- Programs - Harsh
C- Programs - HarshC- Programs - Harsh
C- Programs - Harsh
 

Destaque

солосина неделя игрушки
солосина неделя игрушкисолосина неделя игрушки
солосина неделя игрушки
olesy7
 
In three years time
In three years timeIn three years time
In three years time
Pankratiast
 

Destaque (15)

Ummaya (1)
Ummaya (1)Ummaya (1)
Ummaya (1)
 
солосина неделя игрушки
солосина неделя игрушкисолосина неделя игрушки
солосина неделя игрушки
 
A falta de arte nas artes de um CEO
A falta de arte nas artes de um CEOA falta de arte nas artes de um CEO
A falta de arte nas artes de um CEO
 
Presentación1
Presentación1Presentación1
Presentación1
 
In three years time
In three years timeIn three years time
In three years time
 
Thousand year game v5
Thousand year game v5Thousand year game v5
Thousand year game v5
 
My dream
My dreamMy dream
My dream
 
Mahavir Jayanti
Mahavir JayantiMahavir Jayanti
Mahavir Jayanti
 
Tvm termoventilmec 2010-newsletter-09-imp asp acciaio
Tvm termoventilmec 2010-newsletter-09-imp asp acciaioTvm termoventilmec 2010-newsletter-09-imp asp acciaio
Tvm termoventilmec 2010-newsletter-09-imp asp acciaio
 
Jbs
JbsJbs
Jbs
 
Killer Cover Letters
Killer Cover LettersKiller Cover Letters
Killer Cover Letters
 
CornFinger Investor Pitch Deck (Fall 2010)
CornFinger Investor Pitch Deck (Fall 2010)CornFinger Investor Pitch Deck (Fall 2010)
CornFinger Investor Pitch Deck (Fall 2010)
 
El CRAI Biblioteca de Dret en 5 minuts
El CRAI Biblioteca de Dret en 5 minutsEl CRAI Biblioteca de Dret en 5 minuts
El CRAI Biblioteca de Dret en 5 minuts
 
COLLEGE: How to Pick a School
COLLEGE: How to Pick a SchoolCOLLEGE: How to Pick a School
COLLEGE: How to Pick a School
 
Business Development: Referral Engines
Business Development: Referral EnginesBusiness Development: Referral Engines
Business Development: Referral Engines
 

Semelhante a Cs project

Semelhante a Cs project (20)

Statement
StatementStatement
Statement
 
String
StringString
String
 
C++ file
C++ fileC++ file
C++ file
 
C programming
C programmingC programming
C programming
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
 
2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings 2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings
 
C file
C fileC file
C file
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
C++ file
C++ fileC++ file
C++ file
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Cs project

  • 1. 1. Write a program to accept three integers and print the largest of them? #include<iostream.h> #include<conio.h> void main() { clrscr(); int a,b,c; cout<<“Enter three numbers ”; cin>>a>>b>>c; if(a>b && a>c) cout<<a; else if(b>a && b>c) cout<<b; else if(c>a && c>b) cout<<c; getch(); }
  • 2. 2. Write a program to input a character and check whether a given character is in alphabet or a digit or any other special character. #include<iostream.h> #include<conio.h> void main() { clrscr(); char a; cout<<“Enter a character ”; cin>>a; if(a>= && a<=) cout<<“You have entered a lowercase alphabet”; else if(a>= && a<= ) cout<<“You have entered an uppercase alphabet”; else if(a>= && a<=) cout<<“You have entered a digit”; else cout<<“You have entered a special character”; getch(); }
  • 3. 3. Write a program to print first ten natural numbers and their sum. #include<iostream.h> #include<conio.h> void main() { clrscr(); int a,b=0; for(a=1;a<=10;a++) { cout<<a<<endl; b+=a; } cout<<“Summation ”<<b; getch(); }
  • 4. 4. Write a program to print the following series. 0 1 1 2 3 5 8 13 #include<iostream.h> #include<conio.h> void main() { clrscr(); unsigned long first, second, third, n; first=0; second=1; cout<<“How many elements you want to enter ”<<endl; cin>>n; cout<<first<<endl; for(int i=2; i<n; i++) { third=first+second; cout<<third; first=second; second=third; } getch(); }
  • 5. 5. Write a program to check whether a given number is palindrome or not. #include<iostream.h> #include<conio.h> void main() { int n, num, digit, rev=0; cout<<“Enter any number ”; cin>>num; n=num; do { digit=num%10; rev=(rev*10)+digit; num=num/10; } while(num!=10) cout<<“The reverse of the number is ”<<rev; if(n==rev) cout<<“The number is a Palindrome”; else cout<<“The number is not a Palindrome”; getch(); }
  • 6. 6. Write a program to accept the marks of ten students and store them in an array. Also display the total marks. #include<iostream.h> #include<conio.h> void main() { int n, a[10], t=0; for(n=1;n<=10;n++) { cout<<“Enter the marks of student ”<<n<<endl; cin>>a[n]; t=t+a[n]; } cout<<“The total of the marks is ”<<t; getch(); }
  • 7. 7. Write a program to search for a specific element in a 1-D array through linear search. #include<iostream.h> #include<conio.h> void main() { clrscr(); int a[5], size, i, flag=0, num, pos; cout<<“Enter the number of elements in an array ”; cin>>size; cout<<“Enter the elements of the array ”; for(i=0;i<size;i++) { cin>>a[i]; } cout<<“Enter the element to be searched ”; cin>>num; for(i=0;i<size;i++) if(a[i]==num) { flag=1; pos=i; break; } if(flag==0) { cout<<“Element not found!”; } else { cout<<“Element found at position ”<<pos+1; } getch(); }
  • 8. 8. Write a program to find the number of vowels in a given line of text using an array. #include<iostream.h> #include<conio.h> #include<stdio.h> void main() { clrscr(); char line[100]; int vow=0; cout<<“Enter a sentence ”<<endl; gets(line) ; for(int i=0 ; line[i] !=‘0’;i++) { switch(line[i]) { case ‘a’; case ‘A’; case ‘e’; case ‘E’; case ‘I’; case ‘I’; case ‘o’; case ‘O’; case ‘u’; case ‘U’; vow++; } } cout<<“Total number of vowels in the given line is ”<<vow; getch(); }
  • 9. 9. An array emp[20] contains the number of employees joined in different years. Write a program to find out the number of year in which no employee joined. #include<iostream.h> #include<conio.h> void main() { clrscr(); int emp[20], number_of_year=0; cout<<“Enter the number of employees who joined in ”; for(i=0;i<20;i++) { cout<<“Year is ”<<i+1<<endl; cin>>emp[20]; if(emp[i]==0) number_of_year=number_of_year+1; } cout<<“In ”<<number_of_year<<“ year number of employees joined”; getch(); }
  • 10. 10. Write a program to calculate the length of string without using a library function. #include<iostream.h> #include<conio.h> void main() { clrscr(); char str[20]; int a; for(a=1; a<=20;a++) { cin>>str[a]; } cout<<“Length of string is ”<<a; getch(); }
  • 11. 11. Write a program that checks whether the given character is alphanumeric or a digit by using standard library function. #include<iostream.h> #include<conio.h> #include<string.h> #include<stdlib.h> void main() { char ch; int a; cout<<“Enter a character ”; cin>>ch; a=ch; if(isalnum(a)) { cout<<“Alphanumeric Character”; } else if(isalpha(a)) { cout<<“Alphabetic Character”; } else if(isdigit(a)) { cout<<“Numeric Character”; } else cout<<“Other Character”; getch(); }
  • 12. 12. Write a program to swap two values and make a new program. #include<iostream.h> #include<conio.h> void main() { clrscr(); void swap(int &, int &) int a, b; cout<<“Enter the first number ”; cin>>a; cout<<“Enter the second number ”; cin>>b; swap(a, b); cout<<“After swapping the values are ”<<a<<b; getch(); } void swap(int &x, int &y) { int z; z=x; x=y; y=z; cout<<“The swapped values are ”<<x<<y; }
  • 13. 13. Write a program to generate the following output: #include<iostream.h> #include<conio.h> void main() { int a, b; for(a=1;a<=5;a++) { for(b=1;b<=a;b++) { cout<<“* ”; } cout<<endl; } getch(); } * * * * * * * * * * * * * * *
  • 14. 14. Write a function that finds a sub-string from a given string and returns the string to its caller function. #include<iostream.h> #include<conio.h> void main() {
  • 15. 15. Write a program that generates the following output: #include<iostream.h> #include<conio.h> void main() { int a, b, c, d; for(a=1;a<=4;a++) { for(b=1;b<=a;b++) { cout<<“* ”; } cout<<endl; } for(c=1;c<=3;c++) { for(d=3;d>=c;d‒‒) { cout<<“* ”; } cout<<endl; } getch(); } * * * * * * * * * * * * * * * *