Nakum Anil

PRACTICAL-SET-3

3_1.c
  Write a program for use of putchar( ) and getchar( ) function.

#include<stdio.h>
#include<conio.h>
void main()
{
    char s;
    clrscr();
    s=getchar();
    if(isupper(s))
    {
        putchar(tolower(s));
    }
    if(islower(s))
    {
        putchar(toupper(s));
    }

    getch();
}



3_2.c
  Program to print Patterns.         
 *
 *  *          
 *   *   *    
      *    *   *    *


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for (i=1;i<=5;i++)
{
if(i>4)
{
printf (" ");
}
for (j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}



3_3.c
 Program to print Patterns.   
  1 2 3 4 5            
     2 3 4 5               
       3 4 5                   
          4 5                   
             5


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=5;i++)
   {
    for(k=2;k<=i;k++)
       {
    printf(" ");
       }
    for(j=i;j<=5;j++)
       {
    printf("%d",j);
       }
    printf("\n");
   }
getch();
}



3_4.c
 Program to print Patterns.   
  AAAAA 
  BBBB         
  CCC       
  DD      
  E


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k=65;
clrscr();
for(i=5;i>=1;i--)
   {
    for(j=1;j<=i;j++)
       {
       printf("%c",k);
       }
    printf("\n");
    k++;
   }
getch();
}



3_5.c
 Program to print Patterns.   
 1 
 0 1              
 1 0 1              
 0 1 0 1    


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=5;i++)
   {
    for(j=i;j>=1;j--)
       {
    k=j%2;
    printf("%d",k);
       }
    printf("\n");
   }
getch();
}

No comments:

Post a Comment