Guys I have to subit my lab record tommorow.....i just have some programs left which iam not able to do.:'(

1. Write a program to print the pascal triangle
2. Write a program to concatenate two strings without using teh library functions, by pointers
3. WAP to compare two strings without using library functions by using pointers
4. WAP a function opposite case , to convert accepted strings to pposite case

All these programs in C Language.....It'll be great if some can provide me with the solutions.....The strings chapter was actually not covered for us , so although we completed the entire C language iam not able to it and pascal triangle man its confusing .....I'd appreciate a lot if some one could provide the results.:)


And ya U guys may get annoyed ans say I dint even post what i solved.....what i solved is a whole blunder......

Sorry but we are not in the business of doing people's homework assignments for them.

hey,
you have to show that you have actually tried to solve it by submitting the codes you've written... so that someone can help you where you have a knot.... that is how it is done here.

Ya well i knew u guyz would reply like that....


here ya go...

#include <stdio.h>
#include <conio.h>
int mystrcmp(char *,char *);
void main()
{
int p;
char s1[10],s2[10];
clrscr();
printf("enter the first string\n");
scanf("%s",&s1);
printf("Enter the secong string\n");
scanf("%s",&s2);
p=mystrcmp(&s1,&s2);
 if(p==0)
  printf("Both are same\n");
 else
  printf("Both are different");
getch();
}
int mystrcmp(char *s1,char *s2)
{
 while(*s1==*s2)
  {
   if(*s1=='\0')
    return(0);
   s1++;
   s2++;
  }
 return((*s1)-(*s2));
}

I got it now.....but still dint get others will post what iam did from now....sorry for the trouble

Now what wrong with this code....its to concatenate or join two strings

#include <stdio.h>
#include <conio.h>
int mystrcat(char *,char *);
void main()
{
char s1[10],s2[10],s3[10];
clrscr();
printf("enter the first string\n");
scanf("%s",&s1);
printf("Enter the second string\n");
scanf("%s",&s2);
s3[10]=mystrcat(&s1,&s2);
printf("%s",s3);
getch();
}
int mystrcat(char *s1,char *s2)
{
while(*s1!='\0')
s1++;
if(*s1=='\0')
return((*s1)+(*s2));
}

No errors...byt the o/p is not being displayed

it would be very useful if you wrapped your text in code (

)

Alright mate....did it....

commented: No, you used quote tags, not code tags. -1

the thing is, in this function you are not concatenating the two strings, you are adding together two pointers, which does not solve the problem. what you must do is create a

char *s3

with the length of the two strings added together, and pass the characters one by one into the pointer...

Got it?

ya i got it but not getting the correct code for it...

ur saying first loop
s3=s1
and second loop
s3=s2
and s3[last value]=='\0'...

the coding a little problomatic

nope... what i´m saying is that you s1 into s3 in the first cycle with a while loop. Then, without moving the pointer from the position next to the last character you entered in s3, you continue with s2, transferring characters into the rest of the spaces in s3, and in the end s3=='\0' like this:

while (*s1!='\0')
   *s3==*s1;
   s1++;
   s3++;
}

Thanks Solved It..........Two programs left.....can anyone plz help with the pasal triangle...i searched this forum for pascal triangle and found very complex codes for it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.