PROVIDING CLASSES FOR
COMPUTER SCIENCE (O-A LEVEL/BCA/BTECH/MCA)
[ C , C++ , DATA STRUCTURE,DBMS, COMPUTER ORGANIZATION & ARCHITECTURE, OPERATING SYSTEM,
COMPUTER NETWORKS (DCN), TCP/IP, SOFTWARE ENGINEERING, SOFTWARE PROJECT
MANAGEMENT, COMPUTER GRAPHICS, STRUCTURED SYSTEM ANALYSIS & DESIGN(SSAD),
SYSTEM SOFTWARE/PROGRAMMING, UNIX, DATAWAREHOUSE & DATA MINING, ADVANCE OS (DISTRIBUED),
MANAGEMENT INFORMATION SYSTEM (MIS), CG UNDER C/C++, PROJECT DESIGINING IN
C/C++. PROJECTS IN C/C++ ARE ALSO AVAILABLE]
CONTACT:
NEHA GUPTA
( DOEACC-‘ A’ level, MCA
Guest Faculty At IGNOU &
INDOSS INSITITUTE)
NOTES ON-
_ ______ STRINGS
Q 3 ) COUNT NO.
OF WORDS IN A SENTENCE..
A //count no of words in a sentence
void main()
{
char str[20];
int i,p=1;
clrscr();
puts("\n Enter a string : ");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if (str[i]==' '||str[i]=='\t'||str[i]=='\n')
p=p+1;
}
printf("\n
No. of words : %d",p);
getch();
}
Q 4 Q (6) COUNT
NO. OF VOWELS IN
SENTENCE ..
A //count no of vowels
in a sentence
void main()
{
char str[20];
int i,p=0;
clrscr();
puts("\n Enter a string : ");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if (str[i]=='a'|| str[i]=='A'||
str[i]=='E'|| str[i]=='e'||str[i]=='i'||str[i]=='I'||str[i]=='o'||str[i]=='O'||str[i]=='u'||str[i]=='U')
p=p+1;
}
printf("\n
No. of vowels : %d",p);
getch();
}
Q 5 )
CHANGE THE CASE OF GIVEN
SENTENCE ....ComPuter -> cOMpUTER
A #include<conio.h>
#include<stdio.h>
void main()
{
char s[20];
int i;
clrscr();
puts("\nEnter a string :- ");
gets(s);
printf("\n original text :-");
puts(s);
for(i=0;s[i]!='\0';i++)
{
if(s[i]>= 'A' && s[i]
<='Z')
s[i]=s[i]+32;
else if(s[i]>='a'&&
s[i]<='z')
s[i]=s[i]-32;
}
printf("\n\n");
puts(s);
getch();
}
Q 6 REMOVE SPACE
FROM A STRING.. this is
a pen ->
thisisapen
A #include<conio.h>
#include<stdio.h>
void main()
{
char str1[30],str2[30];
int i,j=0;
clrscr();
puts("\n Enter a string : ");
gets(str1);
for(i=0;str1[i]!='\0';i++)
{
if(str1[i]!='
')
{
str2[j]=str1[i];
j++;
}
}
str2[j]='\0';
puts(str1);
printf("\n");
puts(str2);
getch();
}
Q 7 WRITE
A PROGRAM TO
ACCEPT A NAME (
FIRST, MIDDLE & LAST)
AND PRODUCE THE
FOLLOWING OUTPUT... INPUT:- AMIT
KUMAR SHARMA
OUTPUT:- A.K SHARMA
A void main()
{
char first[10]; or
int i=0; and in printing take
first[i] & middle[i]
char middle[10];
char last[10];
clrscr();
printf("\n Enter the
first name: ");
scanf("%s",&first);
printf(" \n enter the middle name: ");
scanf("%s",&middle);
printf("\n ente r the last name: ");
scanf("%s",&last);
printf("\n Name of the
person %c . %c %s:",first[0],middle[0],last);
getch();
}