This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
PROGRAMS IN GET CERTIFIEDSpell Bee#include <stdio.h>
Letter based Gift Selection# include <ctype.h>#include<process.h>#include<stdio.h>int main(){char a[20],b[20],c[20];char c1;gets(a);gets(b);gets(c);scanf("%c",&c1);for(i=0;a[i]!=NULL;i++)if(islower(a[i]));exit(0);for(i=0;b[i]!=NULL;i++)if(islower(b[i]));exit(0);for(i=0;c[i]!=NULL;i++)if(islower(c[i]));exit(0);If(islower(c1))exit(0);if(a[0]==c1||b[0]==c1||c[0]==c1)printf("yes");elseprintf("no");return 0;}
Counting number of words in a sting (including spaces)#include<stdio.h>
Count the number of even#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();}Sum of the cubes of first N natural numbers#include <stdio.h> int main() { int num, cube, sum = 0, i = 1; printf("Enter the value for n:"); scanf("%d", &num); while (i <= num) { cube = i * i * i; sum = sum + cube; i++; } printf("Sum of cubes of first %d natural" " numbers is %d\n", num, sum);
return 0; }
Prime Factors
D.U. 8
#include <stdio.h>
int main(void) {
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++)
D.U. 9
{
if(a[j]<a[j+1])
{
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;
}
Sum of the Squares of Even numbers.# include <stdio.h>int main(){int n,sum=0,i;scanf("%d",&n);if(n<0){printf("%d is negative number\n",n);
}else if(n>15){ printf("%d is greater than 15",n);
[ 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.
#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;
}
D.U. 22
Daily Allowances
D.U. 23
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.