Post your C/C++ Programs Here

Status
Not open for further replies.
OP
Gigacore

Gigacore

Dreamweaver
Re: Post ur C/C++ Programs Here

A C Program to check whether a given word is Palindrome or not.

Example for Palindromes: MADAM, MALAYALAM, LEVEL, RADAR etc...

Code:
#include <stdio.h>
#include <string.h>
#include<conio.h>
void main()
{
	char str[10],str2[10];
	printf("Enter a string");
	scanf("%",str1);
	strcpy(str2,str1);
	strrev(str2);
	if(strcmp(str1,str2)==0)
		printf("%s is a palindrome",str1);
	else
		printf("%s is not a palindrome",str1);
getch();
}
 

mehulved

18 Till I Die............
Re: Post ur C/C++ Programs Here

Reading this wikipedia article, I feel it's in a grey area so I am deleting the post. If someone can give me the proof that it's legal, I will restore it.
 
OP
Gigacore

Gigacore

Dreamweaver
Re: Post ur C/C++ Programs Here

A Simple C Program to Display the number and its square from 1 to 10 using register variable.

Code:
#include <stdio.h>
#include<conio.h>
void main()
{
		register int count, sqr;
	for(count=1;count<=10;count++)
	{
		sqr=count*count;
		printf("\n%d%d",count,sqr);
	}
getch();
}

EDIT: I added a list of all the PROGRAMS in this thread
 
Last edited:

quan chi

mortal kombat
Re: Post ur C/C++ Programs Here

greetings guys.
well in an urge to make a matrix falling numbers program.(like in the movie):D .i made a simple c++ program which is as follows

Code:
#include<iostream.h>
void main()
{
int counter=0;
loop:
counter++;
cout<<counter<<endl;
goto loop;
}
now the problem is the numbers move from below to up.

and how to exit from this program.once run this program rufuses to exitas it has no termination for loop.:D .

please help me.is there any way by which by pressing 'esc' as like in other programs i an exit from this program.
.
:eek:
 

QwertyManiac

Commander in Chief
Re: Post ur C/C++ Programs Here

Ctrl+Pause|Break or just close that Window. Yours is not a good way to implement this.

Have a look at programs like cmatrix, which create the exact effect. You can source install it on Linux. Or see here:
*www.asty.org/cmatrix.html
 
Re: Post ur C/C++ Programs Here

Code:
#include<iostream.h>
void main()
{
int counter=0;
while(!kbhit())
{
counter++;
cout<<counter<<endl;
}
}
use this.................it will exit on any key press.
 

blackleopard92

In the zone
Re: Post ur C/C++ Programs Here

Gigacore said:
A Simple C Program to Display the number and its square from 1 to 10 using register variable.

Code:
#include <stdio.h>
#include<conio.h>
void main()
{
		register int count, sqr;
	for(count=1;count<=10;count++)
	{
		sqr=count*count;
		printf("\n%d%d",count,sqr);
	}
getch();
}

EDIT: I added a list of all the PROGRAMS in this thread
won't recommend this method in C++, as modern compilers automatically optimise for loops with universal register counters.
 

quan chi

mortal kombat
Re: Post ur C/C++ Programs Here

harryneopotter said:
Code:
#include<iostream.h>
void main()
{
int counter=0;
while(!kbhit())
{
counter++;
cout<<counter<<endl;
}
}
use this.................it will exit on any key press.

thanks harryneopotter

QwertyManiac said:
Ctrl+Pause|Break or just close that Window. Yours is not a good way to implement this.

Have a look at programs like cmatrix, which create the exact effect. You can source install it on Linux. Or see here:
*www.asty.org/cmatrix.html

well thanks for the link.i have downloaded it but how to run it in windows please explain in detail.
 
Last edited:
OP
Gigacore

Gigacore

Dreamweaver
Re: Post ur C/C++ Programs Here

A C Program to find the sum of two matrix using two dimensional array.

Code:
#include <stdio.h>
#include<conio.h>
void main()
{
	int a[10][10],b[10][10],c[10][10];
	int i,j,n,m;
	printf("Enter the order of matrix:);
	scanf("%d%d",&n,&m);
	printf("Enter the elements of matrix")
	for(i=0;i<n;i++)
	for(j=0;j<n;j++)
	scanf("%d",&b[i][j]);
	for(i=0;i<n;i++)
	{
	for(j=0;j<m;j++)
	{
	c[i][j]=a[i][j]+b[i][j];
	}
	}
	printf("Addition of matrices");
	for(i=0;i<n;i++)
	{
	for(j=0;j<n;j++)
	{
	printf("%d\t",c[i][j]);
	}
	printf("\n");
	}
	getch();
	return(0);
getch();
}
 
Last edited:
OP
Gigacore

Gigacore

Dreamweaver
Re: Post ur C/C++ Programs Here

@ mehul... its common to make mistakes sometimes :D .
 
Last edited:
Status
Not open for further replies.
Top Bottom