Programs in Get Certified: Spell Bee
Programs in Get Certified: Spell Bee
Spell Bee
#include <stdio.h>
#include <string.h>
#include <math.h>
#include<ctype.h>
int main(void) {
char s[10],st[10];
int l1,l2,i=0,cnt=0,l=0,cas=0;
scanf("%s",s);
scanf("%s",st);
while(st[i]!='\0' )
{
if(islower(st[i]))
return 0;
else
i++;
}
i=0;
while(s[i]=='\0')
{
if(islower(s[i]))
return 0;
else
i++;
}
l1=strlen(s);
l2=strlen(st);
l=abs(l1-l2);
D.U.
D.U.
D.U.
for(i=0;i<n;i++)
{
if(str[i]==' '||(str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z')||
(str[i]>='0'&&str[i]<='9'))
count++;
else
flag=1;
}
if(flag==0)
printf("%d",count);
else
printf("Invalid Input");
return 0;
}
D.U.
}
if(num==n)
printf("%d is an Armstrong number.",n);
else printf("%d is not an Armstrong number.",n);
}
return 0;
}
Zero Duplicate
#include <stdio.h>
int main(void) {
int a[100],i,j,f,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i]==a[j] && i!=j && a[j]!=0)
{
a[j]=0;
}}}
for(i=0;i<n;i++)
printf("%d ",a[i]);
return 0;
}
#include <stdio.h>
int main(void)
{
int n,s,d;
scanf("%d",&n);
while(n>0)
{
d=n%10;
if(d%2==1)
s+=d;
n/=10;
}
printf("%d",s);
return 0;
}
D.U.
}
if(n<0 ||count!=3)
printf("Invalid Input");
else
{
n=a[1]*100+a[0]*10+a[2];
printf("%d",n);
}
return 0;
}
#include<studio.h>
#include<conio.h>
main()
{
int a[15],count_even=0,i;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
If(a[i]<0)
return 0;
}
for(i=0;i<n;i++)
{
if((a[i]%2 ==0))
count_even++;
}
printf("%d",count_even);
getch();
}
Prime Factors
#include <stdio.h>
int main(void) {
D.U.
int n,i,j,a[50],p=0,temp=0;
scanf("%d",&n);
if(n>0)
{
for(i=2;i<=n;i++)
{temp=0;
if(n%i==0)
{
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{temp=1;
break;
}
}
if(temp==0)
{
a[p]=i;
p++;
}
}
}
for(i=0;i<p-1;i++)
{
for(j=0;j<p-i-1;j++)
{
if(a[j]<a[j+1])
{
D.U.
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
for(i=0;i<p;i++)
printf("%d \n",a[i]);
}
return 0;
}
D.U.
10
return 0;
}
ELECTRICITY BILL
#include <stdio.h>
#include <string.h>
int main(void) {
char input1[50],input2[50];
int input3,bill=0,output,l1,l2,n1=0,n2=0,i;
scanf("%s",input1);
scanf("%s",input2);
scanf("%d",&input3);
l1=strlen(input1);
l2=strlen(input2);
for (i=5;i<l1;i++)
{
n1=n1*10+(input1[i]-48);
}
for (i=5;i<l2;i++)
{
n2=n2*10+(input2[i]-48);
}
if((n1<n2)
bill=-(n1-n2)*input3;
else
bill=(n1-n2)*input3;
printf("%d",bill);
D.U.
11
return 0;
}
DIGITAL ROOTS
#include <stdio.h>
int main(void) {
int n,s,d;
scanf("%d",&n);
if(n>=0 &7 n<=32676)
{
while(n>10)
{
d=n%10;
s+=d;
n/=10;
if(n<10)
{
n+=s;
s=0;
}}
printf("%d",n);
}
return 0;
}
COUNT REPEATED VALUES IN AN INTEGER ARRAY
#include <stdio.h>
int main(void) {
D.U.
12
int a[10],p=0,n,i,f=0,j,t=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]<0)
{
t=1;
break;}
}
if(t==1 || n<0)
printf("Invalid Input");
else
{
for(i=0;i<n;i++)
{
f=1;
for(j=0;j<n;j++)
{
if(a[i]==a[j] && i!=j && a[j]!=-1)
{
a[j]=-1;
f++;
}}
if(f>1)
{
p++;
}}
D.U.
13
printf("%d",p);
}
return 0;
}
PASSWORD
#include<stdio.h>
#include<string.h>
int lenthFunction(char arr[])
{
return strlen(arr);
}
int specialcharacter(char arr[])
{int i,flag=2,count=0;
for(i=0;i<strlen(arr);i++)
{
if(arr[i]=='@' || arr[i]=='_' || arr[i]=='#')
{
count++;
if(count==1)
{
flag=0;
}
else
{
flag=1;
}}}
return flag;
}
int main()
D.U.
14
{
char password[20];
gets(password);
if(lenthFunction(password)<8)
{
printf("Invalid");
}
else if(specialcharacter(password)!=0)
{
printf("Invalid");
}
else if((password[0]>'0' && password[0]<'9')||(password[0]>=33 && password[0]<=64)||
(password[0]>=123 && password[0]<=255 ))
{
printf("Invalid");
}
else if((password[strlen(password)-1]>=33 && password[strlen(password)-1]<=64)&&
(password[strlen(password)-1]>=123 && password[strlen(password)-1]<=255 ))
{
printf("Invalid");
}
else
{
printf("Valid");
}
return 0;
}
SECOND MAXIMUM
#include <stdio.h>
int main()
D.U.
15
{
int a[50],i,j,s,temp=0;
scanf("%d",&s);
for(i=0;i<s;i++)
scanf("%d",&a[i]);
for(i=0;i<s-1;i++)
{
for(j=0;j<s-i-1;j++)
{
if(a[j]<a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("%d",a[1]);
return 0;
}
STUDENT FEE
#include <stdio.h>
int main()
{
int f,m;
scanf("%d",&f);
scanf("%d",&m);
D.U.
16
scanf("%d",&n);
if(n>=0 && n<=32767)
{
while(n>0)
{
d=n%10;
D.U.
17
s+=d;
n/=10;
}
printf("%d",s);
}
return 0;
}
DATE
#include <stdio.h>
#include<string.h>
char *m[12]={"01","02","03","04","05","06","07","08","09","10","11","12"};
int dd[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int main(void)
{
char d[10],mon[3];
int i,n,l,d1,year,mo=0,temp=0;
scanf("%d",&n);
scanf("%s",d);
l=strlen(d);
mon[0]=d[0];
mon[1]=d[1];
mon[2]='\0';
year=(d[6]-48)*1000+(d[7]-48)*100+(d[8]-48)*10+(d[9]-48);
if((year%4==0 && year%100!=0) || (year%400==0))
dd[1]=29;
d1=(d[3]-48)*10+(d[4]-48);
for(i=0;i<12;i++)
{
D.U.
18
if((strcmp(mon,m[i])==0))
{
break;
}}
if(i==12)
temp=1;
if(temp==0)
{
mo=(d[0]-48)*10+(d[1]-48);
if(!(d1>=1 && d1<=dd[mo-1]))
temp=1;
}
if(temp==0)
{
if(l<10 || n<0)
temp=1;
}
if(temp==0)
{
if(!(d[2]=='/' && d[5]=='/'))
temp=1;
}
if(temp==0)
{
for(i=0;i<l;i++)
{
if(i!=2 && i!=5)
D.U.
19
{
if(!(d[i]>=48 && d[i]<=57) )
{
temp=1;
break;
}}}}
if(temp==0)
{
year=(d[6]-48)*1000+(d[7]-48)*100+(d[8]-48)*10+(d[9]-48);
for(i=0;i<6;i++)
printf("%c",d[i]);
printf("%d",(year+n));
}
if(temp==1)
printf("Invalid Year");
return 0;
}
Foo Fighter
#include <string.h>
#include <stdio.h>
int main() {
char st[256];
int l,i,temp=0,j,cnt=0;
gets(st);
l=strlen(st);
for(i=0;i<l;i++) {
if(!(st[i]>='A' && st[i]<='Z'))
D.U.
20
{
return 0;
}
}
if(temp==0) {
for(i=0;i<=l-3;i++)
{
if(st[i]=='F' && st[i+1]=='O' && st[i+2]=='O')
{
cnt++;
}}
for(j=1;j<=cnt;j++)
{
for(i=0;i<=l-3;i++)
{
if(st[i]=='F' && st[i+1]=='O' && st[i+2]=='O')
{
st[i]='O'; st[i+1]='O';
st[i+2]='F';
} }}
printf("%s",st);
}
return 0;
}
[ Input : 100 20 Output: 300 (sum of 20, 40, 60, 80, 100) ] . . . . WAP
to input limit L and the number N & output the sum by multiplying
each time by its own until it reaches upto limit.
D.U.
21
#include <stdio.h>
void add(int,int,int,int);
int main(void) {
int l=0,n,num,s=0;
scanf("%d",&l);
scanf("%d",&n);
num=n;
while(n<=l) {
s=s+n;
n+=num;
}
printf("%d",s);
return 0;
}
Daily Allowances
D.U.
22
Write a program to sum of the numbers till the limit L that are
divisible by number 'n'. Print 'Invalid Input' if L is negative.
D.U.
23
#include <stdio.h>
void add(int,int,int,int);
int main() {
int l=0,n,i,s=0;
scanf("%d",&l);
scanf("%d",&n);
for(i=1;i<=l;i++) {
if(i%n==0)
s+=i;
}
printf("%d",s);
return 0;
}
D.U.
24