^^ Right.
n = num = quo = 5667
che = 6
n = num = quo = 5667
che = 6
#include<stdio.h>
#include<string.h>
main()
{
char a[100];
int i;
gets(a);
for(i=0;a[i]!='\0';i++)
{
for(a[i]>=97&&a[i]<=122)
{
a[i]=a[i]-32; [like say a is 97, so 97-32=65, where 65=A]
}
}
puts(a);
}
#include<stdio.h>
#include<string.h>
main()
{
char a[100],b[100];
int c;
gets(a);
strcopy(b,a); [Copying a to b, like i can reverse b)
strrev(b);
c=strcomp(a,b);
if(c==0)
printf("Palindrome");
else
printf("Not a Palindrome");
}
Here some more basic programs, are they right?
1)Lower case to upper case(Without using functions)
Code:#include<stdio.h> #include<string.h> main() { char a[100]; int i; gets(a); for(i=0;a[i]!='\0';i++) { for(a[i]>=97&&a[i]<=122) { a[i]=a[i]-32; [like say a is 97, so 97-32=65, where 65=A] } } puts(a); }
#include<stdio.h>
#include<string.h>
main()
{
char a[100];
int i;
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]>=97&&a[i]<=122)
{
a[i]=a[i]-32; //[like say a is 97, so 97-32=65, where 65=A]
}
}
puts(a);
}
2)Upper to Lower
#include<stdio.h>
#include<string.h>
main()
{
char a[100];
int i;
gets(a);
for(i=0;a!='\0';i++)
{
for(a>=65&&a<=90)
{
a=a+32;
}
}
puts(a);
}
#include<stdio.h>
#include<string.h>
main()
{
char a[100];
int i;
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]>=65&&a[i]<=90)
{
a[i]=a[i]+32;
}
}
puts(a);
}
3)Check if a word is plaindrome or not using inbuilt functions
EG: ANA,MADAM
Code:#include<stdio.h> #include<string.h> main() { char a[100],b[100]; int c; gets(a); strcopy(b,a); [Copying a to b, like i can reverse b) strrev(b); c=strcomp(a,b); if(c==0) printf("Palindrome"); else printf("Not a Palindrome"); }
4) Palindrome without functions
How do i do this??
#include<stdio.h>
#include<string.h>
main()
{
int a,b,c;
gets(a);
for(i=0;a!='\o';i++)
{
All the programs are not executing , i tried compling them in a online compiler
#include <stdio.h>
#include <string.h>
int main()
{
char string1[20];
int i, length;
int flag = 0;
printf("Enter a string: ");
scanf("%s", string1);
length = strlen(string1);
for(i=0;i < length ;i++)
{
if(string1[i] != string1[length-i-1])
{
flag = 1;
break;
}
}
if (flag)
{
printf("%s is not a palindrome ", string1);
}
else
{
printf("%s is a palindrome ", string1);
}
return 0;
}
From where did you copied this? Do you ever read what error compiler throws? The function names you used are strcopy and strcomp but they are actually strcpy() and strcmp(). Just change that and everything will work fine.