Professional Documents
Culture Documents
# include <stdio.h>
Back # include <conio.h>
main( )
9. Program to accept a number and check the {
given number is Armstrong or not. int n,sum=0,i;
clrscr( );
# include <stdio.h> for (i=1; i<=10; i++)
# include <conio.h> sum=sum+i;
main( ) printf(sum of natural numbers from 1 to
{ 10 is %d\n,sum);
int n, a, b, c, d; getch( );
clrscr( ); }
printf ( Enter a Three Digit Number: ); Back
scanf (%d, &n);
a=n/100; 13. Program to accept a number and print
b=((n/10)%10); mathematical table of the given no.
c=n%10;
d=a*a*a*+b*b*b +c*c*c; # include <stdio.h>
if (n= =d) # include <conio.h>
printf (The Given Number is Armstrong main( )
number); {
else int i,t;
printf (The Given Number is Not clrscr( );
Armstrong number); printf(which table u want:);
getch( ); scanf(%d,&t);
} for (i=1; i<=10; i++)
Back printf(\n%d*%d=%d,t,i,i*t);
getch( );
10. Program to print ODD numbers from 1 to 10 }
Back
{
14. Program to print 1 to 10 mathematical tables int i,j ,l,k=40;
. clrscr( );
for(i=1;i<=9;i+=2)
# include <stdio.h> {
# include <conio.h> for(l=1;l<=k;l++)
main( ) printf( );
{ for(j=1;j<=i;j++);
int i,j; printf(%d,j);
clrscr( ); printf(\n);
for (i=1; i<=10; i++) k=k-2;
for(j=1;j<=10;j++) }
printf(\n%d*%d=%d,i,j,i*j); getch( );
getch( ); }
} Back
96.Program to accept a string in lower case and 98.Program for example of static variable.
print first character of each word in upper case.
#include<conio.h>
#include<conio.h> #include<stdio.h>
#include<stdio.h> static int i=1;
main( ) main( )
{ {
char str1[80]; int j;
int length,i; clrscr( );
clrscr( ); for (j=1;j<=5;j++);
printf(enter a string; ); fun( );
length=getline(str1,80); getch( );
for(i=0;i<length;i++) }
{ fun( )
{
printf(\n%d,i);
i=i+1;
}
Back
#include<conio.h>
#include<stdio.h>
main( )
{
char n,n1;
clrscr ( );
printf(enter a string;);
while((n=getchar( )!=\n)
if(n>=a && n<=z)
putchar(n);
else
if(n>=a && n<=z)
putchar(n);
getch( );
}
Back
#include<conio.h>
#include<stdio.h>
main( )
{
int a[4][4],i,j,c;
clrscr( );
printf(enter which number you want;);
scanf(%d,&c);
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if(i+j= =3)
a[i]]j]=c;
else
a[i][j]=0
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf(%d,a[i][j]);
printf(\n);
}
getch( );
}
Back