Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Crack Master 2014 final round App

Takshak 2014 mar athanasius college 2015 2013 2016 MAC MACE of engineering Thakshak art fest sanskriti tech fest techfest technical computer science department coding cipher encoding encrypted decrypt decode breaking code programming algorithm cash prize money contest kerala MG university
Crack Master 2014 screenshot
Do codes and ciphers make your heart race? When faced with an encrypted message, are you filled with an insatiable curiosity to know just what it is all about? Do you consider yourself to be an unmatched code breaker? If your answer to any of the above questions is a yes, then you would enjoy playing crack master.

2 Different C and C++ Programs to Check Whether a Given String is Palindrome or Not

Here i am writing two different programs to check whether a given string (text) us palindrome or not. There are C and C++ programs for this.

C Programs:

(i) Using string functions:




#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char a[100],b[100];
printf("Enter the string to check if palindrome or not\n");
gets(a);
strcpy(b,a);
strrev(b);
if(strcmp(a,b)==0)
printf("\nEntered string is palindrome");
else
printf("\nEntered string is not palindrome");
getch();
} 

(ii) Comparing Character by Character


#include<string.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int len,i;
char a[100];
printf("Enter the string to check whether it is palindrome or not\n");
gets(a);
len=strlen(a);
for(i=0;i<len/2;i++)
{
if(a[i]!=a[len-i-1])
break;
}

if(i==len/2)
printf("\nEntered string is palindrome");
else
printf("\nEntered string is not palindrome");
getch();
}

C++ Programs:

(i) Using String functions:


Sizeof operator in C

Sizeof operator is a unary operator used in both C and C++ programming languages. This operator is used to get the size of a data type, variable, object of a class, structure variable etc in bytes. In some programs it may be necessary to use the size of certain variable or data type. Such situations often occur in file handling programs. But the size of data type may vary from machine to machine. In most of the 32 bit systems, int has a size of 4 bytes. But in some systems it is 2 bytes. So, if a program is written by assuming the size to be known, it will affect the portability of the program since a change in size of a data type may result in unexpected output. In such cases, the sizeof operator helps to obtain the size of data type or variable in bytes. The argument of sizeof can be a variable of primitive days types (int, char etc), an object (of class), a structure variable, union variable, pointer variables etc. The sizeof operator is very useful in dynamic memory allocation.

C program to show working of sizeof operator:

#include<stdio.h>

struct student

{

char name[5];

int roll;

int mysize;

};

main()
{
unsigned long int b;
printf("size of variable b: %d",sizeof b);
printf("\nsize of int:%d",sizeof(int));
printf("\nsize of float:%d",sizeof(float));
printf("\nsize of char:%d",sizeof(char));
printf("\nsize of long:%d",sizeof(long));
printf("\nsize of double:%d",sizeof(double));
printf("\nsize of short:%d",sizeof(short));
struct student s1;
s1.mysize=sizeof(s1.name)+sizeof(s1.roll)+sizeof(s1.mysize);
printf("\nSizeof structure student :%d",s1.mysize);
/*see the difference shown in size of structure */
printf("\nsize of structure student : %d",sizeof(struct student));
}

Output:

C and C++ Program to Display Pascal's Triangle

This post gives C and C++ programs to display given number of rows of pascal's triangle. Thenuser can enter the number of rows of pascal triangle to be displayed.

C Program:

#include<stdio.h>

#include<conio.h>

long factorial(int);

main()

{

int i, n, c;

printf("Enter the number of rows you wish to see in pascal triangle\n");

scanf("%d", &n);

for (i = 0; i < n; i++)

{

for (c = 0; c <= (n - i - 2); c++)

printf(" ");

for (c = 0; c <= i; c++)

printf("%ld ", factorial(i) / (factorial(c) * factorial(i - c)));

printf("\n");

}

getch();

}