Category Archives: c programming

toggle case

here, the code of toggle

//toggle case
#include<stdio.h>
#include<conio.h>
void main()
{
char str[100];
int i;
clrscr();
printf(“enter string:”);
gets(str);
for(i=0;str[i]!=’\0′;i++)
{
if(str[i]>=’A’&&str[i]<=’Z’)
str[i]+=32;
else if
(str[i]>=’a’&&str[i]<=’z’)
str[i]-=32;
}
printf(“string in toggle case is: %s”,str);
getch();
}

number is armstrong or not

//to check number is armstong or not without arguement and without retern type
#include<stdio.h>
#include<conio.h>
void input();
void process();
int i,j,r,sum,no,temp;
void main()
{
clrscr();
input();
getch();
}
void input()
{
printf(“enter your no”);
scanf(“%d”,&no);
process();
}
void process()
{
for(i=1;i<=no;i++,temp=i)
{
for(j=i;j>0;j=j/10)
{
r=j%10;
sum=sum+(r*r*r);
}
if(temp==sum)
printf(“%d”,temp);
}
}

number is automorphic or not

//to check number isautomorphic or not return type and arguement
#include<stdio.h>
#include<conio.h>
void input();
int process(int);
void output();
int no,i,sqr,r1,r2,flag,x;
void main()
{
clrscr();
input();
getch();
}
void input()
{
printf(“enter your no:”);
scanf(“%d”,&no);
x=process(no);
output(flag);
}
int process(int no)
{
i=no;
sqr=i*i;
for(;i>0;i=i/10,sqr=sqr/10)
{
r1=i%10;
r2=sqr%10;
if(r1!=r2)
{
flag=0;
break;
}
else
flag=1;
}
return x;
}
void output(int flag)
{
if(flag==1)
printf(“automophic”);
else
printf(“not automophic”);
}