Crack Master 2014 screenshot |
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts
Crack Master 2014 final round App
Labels:
2014
,
algorithms
,
app
,
coding
,
college
,
crack
,
Crackmaster
,
decode
,
decryption
,
encode
,
engineering
,
final
,
game
,
MACE
,
Mar Athanasius
,
master
,
round
,
Takshak
,
Thakshak
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:
(ii) Comparing Character by Character
C++ Programs:
(i) Using String functions:
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:
Labels:
$ccpp
,
c language
,
c plus plus
,
C programming
,
C++
,
code
,
coding
,
cpp
,
programming
,
programming language
,
programs
,
project
,
source code
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:
Output:
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:
Labels:
$ccpp
,
c
,
c language
,
c program
,
code
,
coding
,
data type
,
operator
,
programming
,
sample
,
simple
,
size
,
sizeof
,
source code
,
variable
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:
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(); }
Labels:
$ccpp
,
c language
,
c plus plus
,
C programming
,
code
,
coding
,
cpp
,
display
,
pascal's
,
pascals
,
source code
,
triangle
Subscribe to:
Posts
(
Atom
)