Errors and warnings

When I complie my program it said there were 7 errors and 2 warnings. Would someone please find out the errors and warnings and help me to fix it??
Thank you sooooo much.


#include<stdio.h>
#include<stdlib.h>
int square_c(int a);
int lookup_c(char alph);
int main(void)

{

int num;
char alpha;

printf('Enter a number and i will square the value for you.\n');
scanf ('%d', &num);
printf ('The result is %d\n', square_c(num));

printf ('Please enter an alphabet:\n');
scanf ('%s', &alpha);

lookup_c(alpha);

if (lookup_c(alpha) == 0)
printf ('You have entered an alphabet. \n');

else

printf ('The input you have entered is not an alphabet\n');

return(0);

}

int square_c(int a)

{
int result;
result = a * a;
return (result);

}

int lookup_c(char alph)

{

int Char;
if ((alph >= 65 & alph <=90) | (alph >= 97 & alph <= 122))
Char = 0;
else
Char = 1;
return (Char);

}
Where ever you have single quotes ' replace them with double quotes "
Single quotes are used for single characters 'a'
Double quotes are used for strings "this is a string"

Also in your int lookup_c function you have
if ((alph >= 65 & alph <=90) | (alph >= 97 & alph <= 122))
You probably want to check if the first or the second parenthesis is true. The & is the bitwise AND (affects on bits). The condition AND is the &&. The same thing about OR, bitwise OR |, condition OR ||.

Last consider using cout instead of printf and cin instead of scanf.
Last edited on
Topic archived. No new replies allowed.