-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
497ba43
commit fd1d03d
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
try: | ||
a = 10 | ||
b = int(input("Enter any number ")) | ||
c = a/b | ||
print(c) | ||
except: | ||
print('Can not divide number by ZERO') | ||
else: | ||
print("You are able to divide 10 by your inputed number") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* Program to Find the Largest & Smallest Word in a String | ||
made by : rakesh kumar | ||
*/ | ||
#include <iostream> | ||
#include <string.h> | ||
#include <ctype.h> | ||
using namespace std; | ||
int main() | ||
{ | ||
char string[100], word[20], max[20], min[20], c; | ||
int i = 0, j = 0, flag = 0; | ||
cout<<"Enter string: "; | ||
cin.getline(string,100); | ||
|
||
//processing phase | ||
for (i = 0; i < strlen(string); i++) | ||
{ | ||
while (i < strlen(string) && !isspace(string[i]) && isalnum(string[i])) | ||
{ | ||
word[j++] = string[i++]; | ||
} | ||
if (j != 0) | ||
{ | ||
word[j] = '\0'; | ||
|
||
if (flag==0) // this will run only once | ||
{ | ||
flag = 1; | ||
strcpy(max, word); | ||
strcpy(min, word); | ||
} | ||
if (strlen(word) > strlen(max)) | ||
{ | ||
strcpy(max, word); | ||
} | ||
if (strlen(word) < strlen(min)) | ||
{ | ||
strcpy(min, word); | ||
} | ||
j = 0; // for next word in the string | ||
} | ||
} | ||
|
||
//output phase | ||
cout<<"The largest word is '"<<max <<"' and smallest word is '"<<min<<"' in ''"<<string<<"'"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
file = open(r"C:\Users\acer\Desktop\pythonPrograms\fileHandling\abcd.txt",'r') | ||
data1 = file.read() | ||
print(data1) | ||
file.close() |