Various Methods of printing address & value of a variable along with pointers

#include<stdio.h>
main()
{
int a,b,*c,*d,e,f;
printf("Enter values of 2 variables a & b\n");
printf("Value of a:");
scanf("%d",&a);
printf("Value of b:");
scanf("%d",&b);
printf("Printing Address\nMethod I:\nAddress of a= %u, Address of b=%u\n",&a,&b);
c=&a;
d=&b;
printf("Method II:\nAddress of a= %d, Address of b=%d\n",c,d);
printf("Printing Value\nMethod I:\nValue of a = %d, Value of b = %d\n",a,b);
printf("Method II:\nValue of a = %d, Value of b = %d",*c,*d);

}

 

Output:

Output

To find no. of alphabets, digits & white spaces in a string entered by user.

#include<stdio.h>
#include<string.h>
main()
{
int a,b,c=1,d=0,e=0,f=0,g=1;
char s1[100],s2[100];
printf("Enter a string\n");
gets(s1);

b=strlen(s1);
for(a=1;a<=b-1;a++)
{
if(isalpha(s1[a]))
{
c++;
}

if(isspace(s1[a]))
{
e++;
}
if(isdigit(s1[a]))
{
f++;
}
}
printf("Digits = %d, Alphabets = %d, Space = %d",f,c,e);

}

 

Output:

 

Enter a string

hi 55

Digits = 2, Alphabets = 2 & Space = 1