swapping number and alphabet

Question

please help me . where is the problem in choice 1 .. the 1st alphabet is not swapping it’s getting vanished ..

#include<stdio.h>
int main()
{
int choice;
printf(“choicen1:alphabet,n2:numbern”);
scanf(“%d” , &choice);
if(choice==1)
{
char ch1,ch2,temp;
printf(“enter the 1st:”);
scanf(“%s” , &ch1);
printf(“enter the 2nd:”);
scanf(“%s” , &ch2);
temp=ch1;
ch1=ch2;
ch2=temp;
printf(“after swapping the 1st:%cn” , ch1);
printf(“after swapping the 2nd:%c” , ch2);
}

if(choice==2)
{ double first,secound,temp;
printf(“Enter 1st digit:”);
scanf(“%lf” , &first);
printf(“Enter 2nd digit:”);
scanf(“%lf” , &secound);
temp=first;
first=secound;
secound=temp;
printf(“n After swapping the 1st digit :%lfn” , first);
printf(“n After swapping the 2nd digit :%lfn” , secound);
}
return 0;
}

0
Sanjana ayshi 3 months 0 Answers 54 views 0

Leave an answer