Answers for "Write a program in C to print all the alphabets using a pointer"

C
0

Write a program in C to print all the alphabets using a pointer

#include<stdio.h>
#include<stdlib.h>

int main()
{
	
	int *c;	// declare a character pointer
	c = (int *)malloc(sizeof(int));	// assigning memory to c
	
	*c = 'A';	// conpiler automatically convet 'A' to corresponding ASCII value, that is 65
				// the store value is stored in c
		
	// checking if integer pointed by c
	// is less than equal to ASCII value os alphabet 'Z'
	while(*c<='Z'){
		
		printf("%c\n",*c);	// %c prints the character whose ASCII value is equal to *c
		*c = *c + 1;	// increment the integer value that pointer c is pointing to
		
	}
	
}
Posted by: Guest on September-11-2021

Code answers related to "Write a program in C to print all the alphabets using a pointer"

Code answers related to "C"

Browse Popular Code Answers by Language