How to print all the 26 alphabets in this order in C.

AbCdEfGh.....

it should print dynamically from a to z and do not print
this using pgm like this print("Ab......");

Use loops or anything to print all alphabets

Answers were Sorted based on User's Feedback



How to print all the 26 alphabets in this order in C. AbCdEfGh..... it should print dynamical..

Answer / jebarose

This can be done by using ASCII value...
ASCII value of A is 65
ASCII value of b is 98
Difference of Ab,Cd,Ef.(etc) is 33
A to C is 2.

This is the logic,while printing use %c,so tht it gets print
as Alphabets.

Is This Answer Correct ?    12 Yes 1 No

How to print all the 26 alphabets in this order in C. AbCdEfGh..... it should print dynamical..

Answer / nitin garg

#include<stdio.h>
#include<conio.h>
#include<math.h>

int main(){

char ch[26];
int a=65,b=98;
for(int i=0;i<26;i++)
{
ch[i]=a;
printf("%c ",ch[i]);
i++;
a=a+2;
ch[i]=b;
printf("%c ",ch[i]);
b=b+2;

}
getch();
return(0);
}

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

Write any data structure program (stack implementation)

1 Answers   HTC,


Explain the difference between malloc() and calloc() function?

0 Answers  


Write a program to print numbers from 1 to 100 without using loop in c?

0 Answers  


What is a void pointer? When is a void pointer used?

0 Answers   Aspire, Infogain,


Which is better pointer or array?

0 Answers  






What are the types of assignment statements?

0 Answers  


What are linked lists in c?

0 Answers  


Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.

0 Answers   Aspiring Minds,


Can true be a variable name in c?

0 Answers  


In which header file is the null macro defined?

0 Answers  


main() { int x, arr[8]={11,22,33,44,55,66,77,88}; x=(arr+2)[3]; printf(ā€œ%dā€,x); }

8 Answers   Vector,


why effort estimation is important?

1 Answers  


Categories