0% found this document useful (0 votes)
12 views5 pages

Eisha-005 SDC Lab 02

software construction and Development lab.

Uploaded by

ayesha siddiqa
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)
12 views5 pages

Eisha-005 SDC Lab 02

software construction and Development lab.

Uploaded by

ayesha siddiqa
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/ 5

10/8/2021 Software Construction And

Development
Eisha Ter Raazia
2019-BSE-005
Lab2
Code:
Count total number of space,character:
// new.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])


{
char str[100];
int i;
int words=1,characters=0,space=0;
cout<<"Please enter the string \n";
gets(str); //count characters of a string wit out space
i=0;
do{
if(str[i]!=' '){ // check characetrs
characters++;}
else if(str[i]==' ' || str[i] != '\n' || str[i] != '\t'){ // check words
words++;
}
i++;
}
while(str[i] != '\0');
cout<<"\nTotal words: "<<words; //display total number of words
cout<<"\nTotal characters: "<<characters; //display total number of characters
cout<<"\nSpace: "<<(words-1); //display total number of spaces
system("pause");
return 0;
}
Count without space:
// new.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])


{ char str[100];
int i,totChar;
totChar=0;
int space=0;
cout<<"Please enter the string for count characters\n";
gets(str);
i=0;
do{
if(str[i]!=' ') // this condition is used to avoid counting space
{
totChar++;
}
i++;
}while(str[i] != '\0');

cout<<"The total characters of the given string= "<<totChar;


system("pause");
return 0;
}
Task 2:
Create a file (Comiler.cpp) & Implement a Program to read all the content
of a Compiler.cpp (how many lines, how many words and how many
character in the file)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy