Tuesday, 11 December 2012

Implement isalpha

/*This function will chechk whether the input is an alphabate character or not.*/
int myisalpha(int x)
{
if((x >= 65 && x <=90) || (x >= 97 && x <= 122))
return 1;
else
return 0;
}

Implement strstr


/*This program will find the substring s2 from the string s1
* and if found the it reutrns the base address of the substring
* if not found it send zero as a character pointer.
* */
char *mystrstr(const char *string, const char *needle)
{
const char *s1;//For retaing address of second sring for checking
const char *tar; //For retaing address of first string
/*Loop untill end*/
for(; *string != '\0'; string++){
for(s1 = string, tar = needle; *tar != '\0'; s1++, tar++){
if(*s1 != *tar)
break;
}
if(*tar == '\0')
return (char *)s1;
}
return NULL;
}

Implement strcasecmp

/*This function will comapre two string without cases and returns 0 if they are same or the difference of the ascii value if they are difference*/
int mystrcasecmp(const char *s1, const char *s2)
{
while(*s1!='\0' && *s2!='\0'){
if(toupper(*s1) && toupper(*s2)){
s1++;
s2++;
}
else
return(*s1-*s2);
}
return (*s1 - *s2);
}

Inplement strtok

/*It will tokenize the source string "src" from the place where any of the charcter of the
* target string "tar" will be found. It returns the stating address the token string and
* it should catch by a char pointer
* */

char *mystrtok(char *str, const char *tar)
{
static int i; /*For looping*/
static int len1; /*Holds the length of source string*/
static int len2; /*Holds the length of delimiter string*/
static char *s; /*This variable will holds the address of source string*/
int j ; /*For looping*/
int ptr = 0 ; /*Using for recognizing consecutive delimeter found*/
char *token; /*Variable for storing the token*/
token=(char *)malloc(25*sizeof(char)); /*Creating memory for token*/
if(token == NULL) {
printf("Out of memory space!");
exit(0);
}
/* Defining constraints for first time only*/
if(str != '\0') {
i = 0;
s = str;
len1 = strlen(str);
len2 = strlen(tar);
}
i++;
token=(s + i - 1);
/*tokenizing untill last*/
while(i <= len1+1){
ptr++;
for(j = 0 ; j <= len2 ; j++){
if(*(s + i - 1) == *(tar + j)){
*(token + ptr - 1) = '\0';
if(*token == '\0'){
token++;
ptr = 0;
break;
}
else
return token;
}
if(ptr == 0)
continue;
}
i++;
}
return '\0';
}

Implement Strcspn

/*
* This program will check the first unmatched characters of
* target string 'tar' to the source string 'src'
* and returns the total number of first unmatched characters.
* */
int mystrcspn(char *src, char *tar)
{
char *t; /*For retaing the address of tar string*/
int count = 0; /*For counting */
for(;*src != '\0'; src++) {

for(t = tar; *t != '\0'; t++) {
if( *src == *t )
return (count);
}
if(*t == '\0')
count++;
}
return (count);
}

Implement strspn

*
* This program will Count the first matched character
* from target string "tar" to the source string "src"
* and returns the value of count.
* */
int mystrspn(const char *src, const char *tar)
{
const char *t = NULL;/*For retaing the address of target string*/
int count = 0; /*For counting*/
for(;*src != '\0'; src++){
for(t = tar; *t != '\0'; t++)
if(*src == *t){
count++;
break;
}
if(*t == '\0')
return(count);
}
return(count);
}

Implement strrchr

/*
* This program will search for the occurance of a character
* from the last of the string.
* If found it will return the address of last occurance of that character
* */
char *mystrrchr(const char *s1, int x)
{
const char *p = NULL; /*For copying the address of the string for check*/
while(*s1 != '\0'){
if(*s1 == x)
p = s1;
s1++;
}
return(char *)p;
}

Implement strncmp

/*This program will compare the n-bit of a string s1 with s2. If both string are same up to n-bits it will return Zero else it will returns the difference of the ascii value of 1st unmatched character.*/

int mystrncmp(const char *s1, const char *s2, int n)

{

while(s1 != '\0' && (*s1++ == *s2++) && --n > 1)

;

return (*s1 - *s2);

}

Implement strncat

/*This function will append "n" character of source string "src" into target string "tar" & return Zero. */

char *mystrncat(char *tar, const char *src, int n)

{

char *t;/*retaing the address of target string*/

t = tar ;

while (*tar != '\0')

tar++;

/*Copying from src to tar string*/

while (*src != '\0' && (*tar++ = *src++) && (--n > 1));

*tar = '\0';

return t;

}

Implement strncpy


/*This function will copy "n" character of the source string "src" to the target string "tar" and return Zero.*/

char *mystrncpy(char *tar, const char *src, int n)

{

char *t = tar; /*for Retaing the address tar string*/

/*Copying string*/

while(*src != '\0' && (*tar++ = *src++) && n--);

*tar = '\0';

return t;

}

Saturday, 3 November 2012

Daily quiz no.- 04


Daily quiz no.- 04

Answer it!



Comment your answer without watching others comments first! You may explain your answer
Share it with your friend to see what's there answer!


Friday, 2 November 2012

Daily quiz no.- 03

Daily quiz no.- 03

How many triangles are there??



Comment your answer without watching others comments first! You may explain your answer
Share it with your friend to see what's there answer!



Thursday, 1 November 2012

Daily quiz no.- 02

Daily quiz no.- 02

How many squares are in this pic??
What would be the result??


Comment your answer without watching others comments first! You may explain your answer
Share it with your friend to see what's there answer!


Wednesday, 31 October 2012

C programming Quiz 31-35

C programming Quiz 31-35


Quiz 31:
main()
{
static int x=190;
static int y=x;
if(x==y)
printf("equal");
else
printf("unequal");
return 0;
}




Quiz 32:
int increment(int i)
{
i++;
return i;
}
int main()
{
int i;
for(i=0;i<10;increment(i)) printf("%d",i); getch(); }



Quiz 33:
What are the total number of keywords in C?

30
33
32
35



Quiz 34:
What is the output of following program? Assume that stack grows towards lower addresses. Also assume that variables are pushed on to the stack in the order in which they are declared.

main()
{
int x, y;
int *p1 = &x;
int *p2 = &y;
printf("%d\n", p1-p2);
}




Quiz 35:

main()
{
int x = 10;
int y = 20;
if (x <= y == 1) { ++x; } printf("%d\n", x); }


In case of any explanation kindly comment! DON'T FORGET TO JOIN THIS BLOG.. SHARE IT WITH YOUR FRIEND!

Daily quiz no.- 01

Daily quiz no-01

What would be the result??


Comment your answer without watching others comments first! You may explain your answer
Share it with your friend to see what's there answer!



Sunday, 28 October 2012

C programming Quiz 26-30

C programming Quiz 5-10

Quiz 26:
int main()
{
static char s[]="Hai Do It";
int i=0;
char ch;
ch=s[++i];
printf("%c\n",ch);
ch=s[i++];
printf("%c\n",ch);
ch=i++[s];
printf("%c\n",ch);
ch=++i[s];
printf("%c\n",ch);
}



Quiz 27:
main()
{
int c=5;
printf("%d",main||c);
getch();
}


Quiz 28:
main()
{
printf("%d, %d", sizeof("c"), sizeof(100));
}



Quiz 29:
int main()
{
int i = 6;
if( ((++i < 7) && ( i++/6)) || (++i <= 9))
;
printf("%d\n",i);
return 0;
}




Quiz 30:
 int main()
{
 int cnt = 5, a;
do
{
 a /= cnt;
 
}
 while (cnt --);
 printf ("%d\n", a);
 return 0;
 }


In case of any explanation kindly comment! DON'T FORGET TO JOIN THIS BLOG.. SHARE IT WITH YOUR FRIEND!

Wednesday, 24 October 2012

C programming Quiz 21-25

C programming Quiz 21-25

Quiz 21:
int a=1;
printf("%d %d %d", a, ++a, a++);


Quiz 22:
int main()
{

for(putchar('M');putchar('I');putchar('U'))
{
putchar('L');
}
}


Quiz 23:
int main()
{
printf("%d",'+'-'+'-'/'/'/'*'*'/'*');
}


Quiz 24:


int main(){
int i;
for(i = 0; i < 100; i++); { i++ printf("%d", i); }


Quiz 25:
int main()
{
int num=5;
switch(num)
{
default:printf("FACEBOOK\n");
case 1:printf("GOOGLE\n");break;
case 2:printf("GMAIL\n");break;
case 3:printf("ANDROID\n");break;
}
}




In case of any explanation kindly comment! DON'T FORGET TO JOIN THIS BLOG.. SHARE IT WITH YOUR FRIEND!

C programming Quiz 16-20

C programming Quiz 16-20



Quiz 16:
main()
{
float a = 0.7;
if (a < 0.7) printf ("C"); else printf("C++"); }



Quiz 17:
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}


Quiz 18:
main( ) {
int z = 4;
printf( “%d”, printf(“ %d %d “, z, z)); }


Quiz 9:
int main()
{
int x,a=2;
x=++a,++a,a++;
printf("%d %d",x,a);
return 0;
}



Quiz 20:
program1::
main()
{int i=4,x;
x=++i + ++i + ++i;
printf("%d",x);
}

program2::
main()
{
int i=4;
printf("%d",++i + ++i + ++i);
}



In case of any explanation kindly comment!

DON'T FORGET TO JOIN THIS BLOG.. SHARE IT WITH YOUR FRIEND!

Friday, 19 October 2012

C programming Quiz 10-15

C programming Quiz 10-15

<--Previous                                  Page number: 1,2,3                                                          Next-->

Quiz 10:


main()
{
int j,ans;
j = 4;
ans = count(4);
printf("ans=%d\n",ans);
}
int count(int i)
{
if ( i < 0) return(i);
else
return( count(i-2) + count(i-1));
}



Quiz 11:

‎‎#include
int main()
{
int a=3, b = 5;
printf(&a["hi!Hello! how is this? %s\n"], &b["junk/super"]);
printf(&a["WHAT%c%c%c %c%c %c !\n"], 1["this"],2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);
return 0;
}


Quiz 13:
int main(){
int num,a=15;
num=- - - -a--;
printf("%d , %d",num,a);
return 0;}



Quiz 14:
int main(){
int x,i=2;
x=~-!++i;
printf("%d",x);
return 0;}



Quiz 15:

main()
{
char a =0xAA ;
int b ;
b = (int) a ;
b = b >> 4 ;
printf("%x",b);
}

<--Previous                                        Page number: 1,2,3                                                          Next-->

In case of any explanation kindly comment!

DON'T FORGET TO JOIN THIS BLOG.. SHARE IT WITH YOUR FRIEND!

C programming Quiz 5-10

C programming Quiz 5-10

<--Previous                                  Page number: 1,2,3                                                          Next-->

Quiz 6:

#include

int main ()
{
printf("cba\b\b\b");
return 0;
}



Quiz 7:

‎#include
int main()
{
int a,b,c;
a=b=c=10;
c*=b=a*a;
printf("%d %d %d",a,b,c);
}



Quiz 8:
int main ()
{
int a=10;
printf("a-%d\n",a);
{
int a=100;
printf("a=%d\n",a);
a+=100;
}
printf("a=%d\n",a);
return 0;
}



Quiz 9:
void main()
{
int a;
long b;
float c;
double d;
a = b = c = d = 9/2;
printf("%d %ld %f %f",a,b,c,d);
a=b=c=d=9.0/2;
printf("%d %ld %f %f",a,b,c,d);
d=c=b=a=9.0/2;
printf("%d %ld %f %f",a,b,c,d);
}



Quiz 10:

main()
{
int a[][3]={1,2,3,4,5,6};
int (*ptr)[3]=a;
printf("%d %d",(*ptr)[1],(*ptr)[2]);
++ptr;
printf("%d %d",(*ptr)[1],(*ptr)[2]);
}


<--Previous                                  Page number: 1,2,3                                                          Next-->

In case of any explanation kindly comment!

DON'T FORGET TO JOIN THIS BLOG.. SHARE IT WITH YOUR FRIEND!

C programming Quiz 1-5

C programming Quiz 1-5

<--Previous                                           Page number: 1,2,3                                                   Next-->
Quiz 1:

#include
int main(){
int arr[]={6,12,18,24};
int x=0;
x=arr[1]+(arr[1]=2);
printf("x=%d",x);
return 0;



Quiz 2:

int main(){
int x,a=2;
x=++a,++a,a++;
printf("x=%d,a=%d",x,a);
return 0;
}



Quiz 3:
int main()
{
int p=-2,q=0,r=0,s;
clrscr();
s=++p || ++q && ++r;
printf("p=d, q=%d, r=%d, s=%d",p,q,r,s);
getch();
return 0;
}



Quiz 4:
main ()
{
unsigned int i;

for (i = 10; i >= 0; i--)
printf ("%d", i);
}
Options:
a) prints numbers 10 - 0
b) prints nos 10 - 1
c) goes into infinite loop




Quiz 5:

int main()
{
int a=-1,b=0,c=0,d=-1,res;
res=++a || b++ && c++ || ++d;
printf("a=%d,b=%d,c=%d,d=%d,res=%d",a,b,c,d,res);
return 0;
}


<--Previous                        Page number: 1,2                                                                            Next-->

In case of any explanation kindly comment!

DON'T FORGET TO JOIN THIS BLOG.. SHARE IT WITH YOUR FRIEND!

C Programming Quiz

Lets have a programming quiz to know how much you know about programming language!
Brush up your skills of programming here!

As This is the initial stage so we are only doing with C Programming language! We are uploading quiz daily..Don't forget to visit it on daily basis to get the latest updated quiz questions!

Lets start quiz!

C Programings quiz:
[Choose page number given below]
Page 1 [Quiz no- 1 to 5]
Page 2 [Quiz no- 6 to 10]
Page 1 [Quiz no- 11 to15]
Page 1 [Quiz no- 16 to 20]
Page 1 [Quiz no- 21 to 25]
Page 1 [Quiz no- 26 to 10]