You are on page 1of 4

Sindh Madressatul Islam University

Faculty of Computer Science


1st Semester Fall 2019 Class 1B
Course Supervisor: Syeda Nazia Ashraf

Name : Muhammad Faizan


Roll no : CSC-19F-071
Section : 1B

Assignment 2
1. Write a program that take character input from user and determine it is capital letter,
small letter, digit or special character.
Program:
#include <stdio.h>
#include<conio.h>
void main()
{
char ch; OUTPUT:
clrscr();
printf("Enter any character: ");
scanf("%c", &ch);
if(ch >= 'a' && ch <= 'z')
{
printf("'%c' is small letter.", ch);
}
else if(ch >= 'A' && ch <= 'Z')
{
printf("'%c' is capital letter.", ch);
}
else if(ch >= '0' && ch <= '9')
{
printf("'%c' is digit.", ch);
}
else
{
printf("'%c' is special character.", ch);
}
getch();
}

2. Write a program which shows the output of character, exponential and unsigned decimal
integer.
Program:
OUTPUT:
#include<stdio.h>
#include<conio.h>
void main(void)
{
int i=247;
char c='L';
double e=1.234e5;
clrscr();
printf("\nYou write = %e",e);
printf("\nYoy write = %c",c);
printf("\nYou write = %u",i);
getch();
}

3. Write a program to print asterisks (*), starting with one increasing one asterisk in the
following line until number of asterisks reaches to 10.
SAMPLE OUTPUT:

Program: OUTPUT:
#include<stdio.h>
#include<conio.h>
void main(void)
{
int i,j;
for(i=1;i<=10;i++)
clrscr();
{
for(j=1;i>=j;j++)
printf("*");
printf("\n");
}
getch();
}
4. Write a program to print asterisks (*) from 1 to 5 diagonally.
SAMPLE OUTPUT:
*
*
*
*
*
Program:
#include <stdio.h>
#include<conio.h>
void main()
{
OUTPUT:
int i, j;
clrscr();
for(i=1; i<=5; i++)
{
for(j=1; j<i; j++)
{
printf(" ");
}
j=1;
{
printf("*");
}
printf("\n");
}
getch();
}

5. Write a program to print a string with the first character increasing one character in
the following line until the end of the string is reached.
Program:
#include<stdio.h>
#include<conio.h> Output:
void main()
{
char s[]="PAKISTAN";
int a,b;
for(a=0;s[a];a++)
{
for(b=0;b<=a;b++)
printf("%c",s[b]);
printf("\n");
}
getch();
}

You might also like