SlideShare a Scribd company logo
D e p a r t m e n t o f M e t a l l u r g i c a l E n g i n e e r i n g
N E D U n i v e r s i t y
Computer Programming
Syed Muhammad Tanveer
IM-207
1
2
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
clrscr();
int a;
char ch[80];
printf("Enter a string: ");
gets(ch);
printf("n");
int b=strlen(ch);
for(a=0;a<b;a++)
{
if (ch[a]>64&&ch[a]<91)
ch[a]=ch[a]+32;
else
if (ch[a]>96&&ch[a]<123)
ch[a]=ch[a]-32;
}
puts(ch);
printf("nTotal words =%dn",b);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b;
clrscr();
printf("enter a number: ");
scanf("%d",&a);
if (a%2==0)
printf(" number is evenn ");
else
printf("number is oddn");
for (b=1;b<=10;b++)
printf("%d x %d = %dn",a,b,a*b);
getch();
}
/* Assigment # 3 */
#include<stdio.h>
#include<conio.h>
void main(void)
{ int a,b;
char ch= 'e'||'o';
clrscr();
printf("enter a number : ");
scanf("%c",&ch);
for(a=1;a<=10;a++)
{
if (ch=='e')
for(b=1;b<=10;b++)
{
if (a%2==0)
printf("%d x %d = %dn",a,b,a*b);
}
else if (ch=='o')
for (b=1;b<=10;b++)
{
if (a%2==1)
printf("%d x %d = %dn",a,b,a*b);
}
}
/* Assignment # 3 */
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b;
char ch;
clrscr();
printf("Press e or o : ");
scanf("%c",&ch);
switch (ch)
{
case 'e':
for(a=1;a<=10;a++)
{
if (a%2==0)
for (b=1;b<=10;b++)
printf("t%d x %d =
%dn",a,b,a*b);
}
break;
case 'o':
for(a=1;a<=10;a++)
{
3
getche();
}
if (a%2!=0)
for (b=1;b<=10;b++)
printf("t%d x %d = %dn",a,b,a*b);
}
break;
default:
printf("Error...nPlease pressn e tables of
even numbersnORn o for tables of odd
numbers ");
break;
}
getche();
}
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main(void)
{
int a,b;
clrscr();
for(a=1,b=1;a=5,b<=10;a++,b++)
{
textcolor(1);
textbackground(4);
cprintf("%d x %d = %d",a,b,a*b);
printf("n");
}
gotoxy(30,10);
printf(“I m Here “);
getche();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
clrscr();
int a;
char ch[80];
printf("Enter a string: ");
gets(ch);
printf("n");
int
slen=strlen(ch);
for(a=0;a<slen;a++)
{
if
(ch[a]=='e'||ch[a]=='a'||ch[a]=='o'||ch[a]=='u'||
ch[a]=='i')
printf("%c",ch[a]-32);
else
printf("%c",ch[a]);
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
clrscr();
int i,j,slen,temp;
char A[]="muprteco";
slen=strlen(A);
printf("Enter element in arrayn");
for(i=0;i<slen;i++)
{
printf("Alphabet %d = %c",i+1,A[i]);
printf("n");
}
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a[100],n,i,beg,end,mid,item;
printf("n------- BINARY SEARCH -------
nn");
printf("Enter No. of Elements= ");
scanf("%d",&n);
printf("nEnter Elements in Sorted
Order=n");
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
printf("nEnter Item you want to
4
printf("n Element enter by you is : n");
for(i=0;i<slen;i++)
printf("%cn",A[i]);
for(i=0;i<slen;i++)
{
for(j=i+1;j<slen;j++)
if (A[i]<A[j])
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
printf("%ct",A[i]);
}
getch();
}
Search= ");
scanf("%d",&item);
beg=1;
end=n;
mid=(beg+end)/2;
while(beg<=end && a[mid]!=item)
{
if(a[mid]<item)
beg=mid+1;
else
end=mid-1;
mid=(beg+end)/2;
}
if(a[mid]==item)
printf("nData is Found at Location : %d",--
mid);
else
printf("Data is Not Found");
getch();
}
#include<stdio.h>
#include<conio.h>
main(){
const int a=2, b=0;
int c=0;
clrscr();
printf("Value of a = %d",a*4);
c = a*4;
printf("Value of a = %d",c);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int a=2;
const int b=2;
printf("%d * %d = %d",a,b,a*b);
/*b++; b is constant , b++ error */
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main(void)
{
clrscr();
int a,count=0,cons=0,space=0;
char ch[80];
printf("Enter a string: ");
gets(ch);
int b=strlen(ch);
for(a=0;a<b;a++)
{
if (isspace(ch[a]))
space++;
else if (ch[a]=='e' || ch[a]=='a'|| ch[a]=='o'|| ch[a]=='u'
|| ch[a]=='i')
/* IMPORTANT FUNCTION QUESTION */
#include<stdio.h>
#include<conio.h>
int input(void);
void main()
{ clrscr();
int num=input();
printf("nReturned Value
=%d",num);
getch(); }
int input (void)
{
int a,b;
printf("enter first number : ");
scanf("%d",&a);
printf("enter second number : ");
scanf("%d",&b);
float c=(float) a/b;
5
count++;
else if (ch[a]!=' ')
cons++;
}
printf("Total
Character=%dtVowels=%dtConsonant=%dtSpace=%d",
b-space,count,cons,space);
getch();
}
printf("ntt%d divided by %d= %.3f",a,b,c);
return (a-b);
}
/* Post-fix & Pre-fix Decreament */
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("ttPost-fix & Pre-fix
Decreamentn");
int
x=10,y=20,z=30,a=40,b=50,c=60,e=80,d=70,f=90;
printf("t%d and %dn",x,x);
printf("t%d and %dn",y,y--);
printf("t%d and %dn",z,--z);
printf("t%d and %dn",a--,a);
printf("t%d and %dn",b--,b--);
printf("t%d and %dn",c--,--c);
printf("t%d and %dn",--d,d);
printf("t%d and %dn",--e,e--);
printf("t%d and %dn",--f,--f);
getch();
}
/* Post-fix & Pre-fix Increament */
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("ttPost-fix & Pre-fix
Increamentn");
int
x=10,y=20,z=30,a=40,b=50,c=60,e=80,d=70,f=90
;
printf("t%d and %dn",x,x);
printf("t%d and %dn",y,y++);
printf("t%d and %dn",z,++z);
printf("t%d and %dn",a++,a);
printf("t%d and
%dn",b++,b++);
printf("t%d and
%dn",c++,++c);
printf("t%d and %dn",++d,d);
printf("t%d and
%dn",++e,e++);
printf("t%d and %dn",++f,++f);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
int a[10][10];
int b[10][10];
int i,j,k,c[10][10],r1,c1,r2,c2,sum=0;
clrscr();
printf("ttMultiplication of Two Matricesn");
/*FOR MATRICS A */
printf("nMatrics A");
printf("nEnter No of Row :");
scanf("%d",&r1);
printf("nEnter No of Column :");
scanf("%d",&c1);
for(i=0;i<r1;i++)
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
char ch;
int i,j,n,temp;
int A[10];
printf("Enter the no of element:");
scanf("%d",&n);
printf("Enter element in arrayn");
for(i=0;i<n;i++)
{
printf("Element %d is ",i+1);
scanf("%d",&A[i]);
}
printf("n Element enter by you is :
6
for( j=0;j<c1;j++)
{
printf("nEnter A[%d][%d] : ",i,j);
scanf("%d",&a[i][j]);
}
for(i=0;i<r1;i++)
{
printf("n");
for(j=0;j<c1;j++)
printf("%dt",a[i][j]);
}
printf("n");
/*FOR MATRICS B */
printf("nMatrics B");
printf("nEnter No of Row :");
scanf("%d",&r2);
printf("nEnter No of Column :");
scanf("%d",&c2);
for(i=0;i<r2;i++)
for( j=0;j<c2;j++)
{
printf("nEnter b[%d][%d] : ",i,j);
scanf("%d",&b[i][j]);
}
for(i=0;i<r2;i++)
{
printf("n");
for( j=0;j<c2;j++)
printf("%dt",b[i][j]);
}
getch(); }
printf("nPress Enter... ");
clrscr();
if (r1==c2)
{ /*FOR MATRICS C */
printf("nMatrics c=a*bn");
for(i=0;i<r1;i++)
for(j=0;j<c2;j++)
{
sum=0;
for (k=0;k<c2;k++)
sum=sum+a[i][k]*b[k][j];
c[i][j]=sum;
}
for(i=0;i<r1;i++)
{
for( j=0;j<c2;j++)
printf("%dt",c[i][j]);
printf("n");
}
}
else
printf("nCould Not Multiply because Row of b != Column
of b ");
n");
for(i=0;i<n;i++)
{
printf("%dn",A[i]);
}
printf("If you want to sort in ascending
ordertpress a
tttOrnIf you want to sort in
descending ordertpress bnt");
ch=getche();
if (ch=='a')
{
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if (A[i]>A[j])
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
}
printf("t%dt",A[i]);
}
}
else
if (ch=='b')
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{ if (A[i]<A[j])
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
}
printf("t%dt",A[i]);
}
getche();
}
7
getch();
}
#include<stdio.h>
#include<conio.h>
void power(int a,int b);
void main()
{ clrscr();
int a,b;
printf("Enter a number ");
scanf("%d",&a);
printf("%d ki power ",a);
scanf("%d",&b);
power(a,b);
getch(); }
void power(int a, int b)
{ long int e,c;
e=a;
for (int s=1;s<b;s++) e=e*a;
printf("t=%ld",e);
int i,n;
printf("nSquare of ");
for (i=1;i<=a;i++)
c=a*a;
printf("%d is %ld",a,c);
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b;
char c;
do
{
clrscr();
printf("enter a number: ");
scanf("%d",&a);
for (;a<=b;a++)
{ if (a%2==0)
for (b=1;b<=10;b++)
printf("%d x %d = %dn",a,b,a*b);
}
c= getche();
}
while (c=='f' || c =='F');
getch();
}
8
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
clrscr();
int a,b;
char str[50];
printf("Enter a string:t");
gets(str);
strrev(str);
printf("%s",str);
a=strlen(str);
b=a;
printf("Reverse string:t");
while (b>=0)
{
printf("%c",str[b]);
b--;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b;
clrscr();
for(b=1;b<=10;b++)
{
for(a=1;a<=10;a++)
printf("t%d",b*a);
printf("n");
}
getche();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
int num =20;
clrscr();
/*((num%2==0)? 1:0); */
((num%2==1)?printf("nEven"):printf("nOdd"));
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
char c =65;
clrscr();
printf("character =%c, Its code= %d",c,c);
printf("nTanveer "Raza"");
getch();
}
#include<stdio.h>
#include<conio.h>
//#include<string.h>
//void printmsg(void);
void printmsg(void)
{
printf("NED University of Engg. & Tech.");
printf("n Department of Metallurgical engg.");
#include<stdio.h>
#include<conio.h>
main()
{
int num[2][2];
int i,j;
clrscr();
for(i=0;i<2;i++)
for(j=0; j<2; j++)
{
9
}
main(){
clrscr();
printmsg();
getch();
}
printf("enter number :");
scanf("%d",&num[i][j]);
}
clrscr();
for(i=0;i<2;i++)
{
for(j=0;j<2; j++)
printf(" %dt",num[i][j]);
printf("n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int a=21,e=0,o=0;
while(a<=50)
{
if (a%2==0)
e=e+a;
else
o=o+a;
a++;
}
printf("Sum of Odd Numbers from 21-50=t%d",o);
printf("nSum of Even Numbers from 21-
50=t%d",e);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int c=0;
char ch;
while((ch=gethe())!=’r’)
{
c++;
if (ch==’a’)
a++;
else if (ch==’e’)
e++;
else if (ch==’u’)
u++;
else if (ch==’o’)
o++;
else if (ch==’i’)
i++;
}
printf(“nCharacter=%dnAs=%dnEs=%dnIs=%dnOs=
%d
nUs=%d”,c,a,e,i,o,u);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
main(){
char str[20];
int len;
clrscr();
printf("Enter a string :");
scanf("%[^n]s",str);
len = strlen(str);
#include<stdio.h>
#include<conio.h>
main(){
clrscr();
char name[30]; //="Metallurgy";
int i=0;
while(name[i]!='o')
{
//gotoxy(30,10);
printf("%c",name[i]);
10
printf("nLength of string = %d",len);
getch();
}
i++;
}
//scanf("%s",name);
//gets(name);
//puts(name);
//printf("%s",name);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b;
char c;
//int a,b;
do {
clrscr();
scanf("%d%d",&a,&b);
//while (a>1,b<=10)
//for(;a<=100;a++)
//for (b=25;a<=25,b>=1;a++,b--)
{
printf("%d + %d = %dn",a,b,a+b);
a--,b++;
//printf("%d",a);
//printf("%d %dn",a,b);
getche();
}
/*printf("Engr. Syed Muhammad Tanveern");*/
//printf("tProud to be a "Pakistani"");
} while (c=='f');
getche();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
clrscr();
int i,j,A[2][2];
int max_num;
for(i=0;i<2;i++)
for( j=0;j<2;j++)
{
printf("nEnter A[%d][%d] : ",i,j);
scanf("%d",&A[i][j]);
}
for(i=0;i<2;i++)
{
printf("n");
for(j=0;j<2;j++)
printf("%dt",A[i][j]);
}
max_num=A[0][0];
for (i=0;i<2;i++)
for( j=0;j<2;j++)
{
printf("%dt",A[i][j]);
if (A[i][j]>=max_num)
max_num=A[i][j];
}
printf("nMaximun number = %d",max_num);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
char ch[60]="Mike";
sizeof(ch);
printf("nsize of ch = %d",sizeof (ch));
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int max_num,a,count=0;
int arr[10]={10,20,30,30,30,40,50,40,50,50};
max_num=arr[0];
for (a=0;a<10;a++)
{ printf("%dt",arr[a]);
if (arr[a]>=max_num)
11
max_num=arr[a];
count++;
}
printf("Maximun number = %d times=%d",max_num,--
count);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b;
clrscr();
for (a=1;a<=7;a++)
{
for (b=1;b<=a;b++)
if (b%2==1 && a%2==1)
printf("%dt",b);
printf("n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
clrscr();
int a,b;
char str[50];
printf("Enter a string....");
gets(str);
printf("n");
a=strlen(str);
for (b=a;b>=0;b--)
printf("%c",str[b]);
getch();
}
12
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
clrscr();
int a,b;
char ch[80],c='w';
printf("Enter a string: ");
gets(ch);
b=strlen(ch);
for(a=0;a<b;a++)
{
if (ch[a]==c)
printf("%c",'e');
else
printf("%c",ch[a]);
}
printf("nTotal words =%dn",b);
getch();
}
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
int a=4,*b;
b=&a;
printf("Value of a=%d and its address=%un",a,&a);
printf("Value of b=%d and its address=%un",*b,b);
printf("value of a=%d and b=%d",a,*b);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
clrscr();
int a,b;
char ch[80];
printf("Enter a string: ");
gets(ch);
printf("nCharcter ASCII Equivalentn ");
b=strlen(ch);
for(a=0;a<b;a++)
{
printf("%c t %d",ch[a],ch[a]);
printf("n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int a,count=0;
printf("Enter a number : ");
scanf("%d",&a);
for (int i=1;i<=a;i++)
{
if (a%i==0)
count++;
}
if (count==2)
printf("Number is Prime");
else
printf("Not a Prime Number");
getch();
}
/* SWAP THE VALUES BETWEEN 2INTEGER
#include<stdio.h>
13
VARIABLES */
#include<stdio.h>
#include<conio.h>
void readint (int *a,int *b);
void swap (int *a,int *b);
int main(void)
{ clrscr();
int num1,num2;
readint(&num1,&num2);
printf("Before swapping num1=%d and
num2=%d n",num1,num2);
swap(&num1,&num2);
printf("After Swapping num1=%d and
num2=%dn",num1,num2);
getch();
return 0;
}
void readint(int *a,int *b)
{
printf("Enter first Integer number :");
scanf("%d",a);
printf("Enter second integer number :");
scanf("%d",b);
}
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
#include<conio.h>
#include<stdlib.h>
void main(void)
{
clrscr();
int a=15;
printf(“a=%d and it equivalent octal =%o”,a,a);
printf(“a=%d and it equivalent hexa =%x”,a,a);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{ clrscr();
int a,b;
float per=0;
printf("tttThis Program Calculate Percentage &
Graden");
printf("Enter Obtained Marks:");
scanf("%d",&a);
printf("Enter Total Marks:");
scanf("%d",&b);
per=((float)a/b)*100;
printf("Percentage=%.2f%n",per);
if (per>60 && per<70)
printf("Grade B");
else if (per>70 && per<80)
printf("Grade A");
else if (per>80 && per<=100)
printf("Grade A-one");
else if (per>50 && per<60)
printf("Pass");
else
printf("Fail");
/* swaps the values between 2 integer variables */
#include <stdio.h>
#include<conio.h>
void swap (int a, int b);
main (void ) {
int num1=40,num2=50;
clrscr();
printf("before swapping num1= %d,
num2=%dn",num1,num2);
swap(num1,num2);
getch();
}
void swap (int a, int b) {
int temp;
temp=a;
a=b;
b=temp;
printf("nAfter swapping num1= %d,
num2=%dn",a,b);
return;
}
14
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int i,j,temp,A[10]={78,45,9,11,12,2,100,4,6,5};
printf("Elemnts of Array In Asecending Ordern");
for(i=0;i<10;i++)
{
for(j=i+1;j<10;j++)
if (A[i]>A[j])
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
printf("%dt",A[i]);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int a=1;b=0;
while(a<=10)
{
b=b+a;
printf(“Sum of Number =%d n”,b);
a++;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int r,c,i,j,A[10][10],B[10][10],C[10][10];
printf("Enter number of row:");
scanf("%d",&r);
printf("Enter number of Columns:");
scanf("%d",&c);
printf("Matrix An");
for (i=0;i<r;i++)
for (j=0;j<c;j++)
{
printf("Enter Element of A[%d][%d]=:",i,j);
scanf("%d",&A[i][j]);
}
for (i=0;i<r;i++)
{ for (j=0;j<c;j++)
printf("%dt",A[i][j]);
printf("n");
}
printf("Matrix Bn");
for (i=0;i<r;i++)
for (j=0;j<c;j++)
{
printf("Enter Element of B[%d][%d]=:",i,j);
scanf("%d",&B[i][j]);
}
for (i=0;i<r;i++)
{ for (j=0;j<c;j++)
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int a=1;b=1;
for (a=1;a<=10;a++)
{
for (b=1;b<=10;b++)
printf(“%d t”,a*b);
printf(“n”);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
for (a=0;a<11;a++)
{
if (a==4 || a==7)
continue;
printf(“Value of a is %dn”,a);
}
15
printf("%dt",B[i][j]);
printf("n");
}
printf("Matrix C=A+Bn");
for (i=0;i<r;i++)
{ for (j=0;j<c;j++)
printf("%dt",A[i][j]+B[i][j]);
printf("n");
} getch();
}
for (a=0; ;a++)
{
printf(“Value of a is %dn”,a);
if (a>5)
break;
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main (void)
{
clrscr();
char wwe;
char ch;
int i,j,n,temp;
int A[10];
int x,y,slen,pemt;
printf("For number's sorting press s nFor alphabetic sorting press pnYour Choicet");
scanf("%c",&wwe);
switch (wwe)
{
case 's':
printf("ttSortingn");
printf("Enter the no of element:");
scanf("%d",&n);
printf("Enter element in arrayn");
for(i=0;i<n;i++)
{
printf("Element %d is ",i+1);
scanf("%d",&A[i]);
}
printf("n Element enter by you is : n");
for(i=0;i<n;i++)
{
printf("%dn",A[i]);
}
printf("If you want to sort in ascending ordertpress anOrnIf you want to sort in
descendingordertpress bnt");
printf("n");
ch=getch();
if (ch=='a')
{
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if (A[i]>A[j])
16
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
}
printf("t%dt",A[i]);
}
}
else
if (ch=='b')
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{ if (A[i]<A[j])
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
}
printf("t%dt",A[i]);
}
break;
case 'p':
clrscr();
char Z[100];
printf("Enter a string:");
fflush(stdin);
gets(Z);
slen=strlen(Z);
printf("Enter element in arrayn");
for(x=0;x<slen;x++)
{
printf("Alphabet %d = %c",x+1,Z[x]);
printf("n");
}
printf("n Element enter by you is : n");
for(x=0;x<slen;x++)
{
printf("%cn",Z[x]);
}
printf("If you want to sort in ascending ordertpress a
nOrnIf you want to sort in descendingordertpress bnt");
printf("n");
ch=getch();
if (ch=='a')
{ for(x=0;x<slen;x++)
{
for(y=x+1;y<slen;y++)
if (Z[x]>Z[y])
{
pemt=Z[x];
17
Z[x]=Z[y];
Z[y]=pemt;
}
printf("t%ct",Z[x]);
}
}
else
if (ch=='b')
{
for(x=0;x<slen;x++)
{
for(y=x+1;y<slen;y++)
{
if (Z[x]<Z[y])
{
pemt=Z[x];
Z[x]=Z[y];
Z[y]=pemt;
}
}
printf("t%ct",Z[x]);
}
}
break;
}
getche();
}
#include<stdio.h>
#include<conio.h>
int inputnum(void)
{
int num;
clrscr();
printf("Enter a Number :");
scanf("%d",&num);
printf("n");
return num;
}
void table(void)
{
int num2;
num2= inputnum();
for(int i=1; i<11; i++)
{
printf("%d x %d =
%dn",num2,i,num2*i);
}
}
void cont (void)
{
char ch;
#include<stdio.h>
#include<conio.h>
void heading(void)
{
printf("NED university of Engg. & Tech.n");
printf("Department of Metallurgical Engg.");
}
void add(int a,int b)
{
//int num1=4, num2=6;
printf("%d + %d = %d",a,b,a+b);
}
void table(int a)
{
//int num=2;
clrscr();
for(int i=1; i<11; i++)
printf("%d x %d = %dn",a,i,a*i);
//getch();
}
18
do
{
clrscr();
table();
printf("n Press Y/y for Continue..... :");
ch=getche();
}
while(ch=='Y' || ch=='y');
}
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<string.h>
void main ()
{
clrscr();
int i=0;
char str[]="CS6";
int slen=strlen(str);
while (i<slen)
{
if (isalpha(str[i]))
printf ("character %c is alphabeticn",str[i]);
else
printf ("character %c is not alphabeticn",str[i]);
i++;
}
getch();
}
#include<ctype.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main(void)
{
clrscr();
char arr[100];
printf("Type: ");
gets(arr);
int isdigit,slen=strlen(arr);
for (int i=0;i<slen;i++)
{
printf("n%d word is a : ",i+1);
if (isdigit(arr[i]))
printf("Digit");
else
printf("Character");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
int vowel=0,c=0;
char ch;
while((ch=getch())!=’r’)
{
c++;
if (ch==’a’ || ch==’u’ || ch==’o’ || ch==’i’ || ch==’e’ )
vowel++;
}
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
int num=0,i=0;
for ( ;num<=256;num++)
{
printf(“%d : %cn”,num,num);
i++;
if (i==24)
printf(“Press any key to continue….”);
getch();
19
printf(“Character=%dnVowel=%d”,c,vowel);
getch();
}
clrscr();
i=0;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
int id;
printf(“Enter a number less than 4:”);
scanf(“%d”,&id);
switch (id)
{
case 1:
printf(“A”);
break();
case 1:
printf(“B”);
break();
case 1:
printf(“C”);
break();
defaut:
printf(“Not Found”);
break();
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
int a=1,b=0;
while (a<=10)
{
b=b+a;
printf(“nsum of Number %d + %d=%d”,a,a+1,b);
a++;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void power(int a,int b);
void main()
{ clrscr();
int a,b;
printf("Enter a number ");
scanf("%d",&a);
printf("%d ki power ",a);
scanf("%d",&b);
power(a,b);
printf("nSum %dn",a+b); printf("Subtraction %dn",a-b);
printf("Multiplication %dn",a*b); printf("Divison %.3fn",(float)a/b);
printf("Remiander %dn",a%b);
getch(); }
void power(int a, int b)
{ long int e,c;
20
e=a;
for (int s=1;s<b;s++) e=e*a;
printf("t=%ld",e);
int i,n;
printf("nSquare of ");
for (i=1;i<=a;i++)
c=a*a;
printf("%d is %ld",a,c); }

More Related Content

What's hot

Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
Murali Kummitha
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanriturajj
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...
Salar Delavar Qashqai
 
C basics
C basicsC basics
C basicsMSc CST
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
Sazzad Hossain, ITP, MBA, CSCA™
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 
Daa practicals
Daa practicalsDaa practicals
Daa practicals
Rekha Yadav
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Salar Delavar Qashqai
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
C programms
C programmsC programms
C programms
Mukund Gandrakota
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)vinay arora
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
Arkadeep Dey
 
Data structure output 1
Data structure output 1Data structure output 1
Data structure output 1
Balaji Thala
 

What's hot (20)

Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
 
programs
programsprograms
programs
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshan
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...
 
C basics
C basicsC basics
C basics
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
C programs
C programsC programs
C programs
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
Daa practicals
Daa practicalsDaa practicals
Daa practicals
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
C programms
C programmsC programms
C programms
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
Data structure output 1
Data structure output 1Data structure output 1
Data structure output 1
 

Similar to Cpd lecture im 207

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Arrays
ArraysArrays
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 
(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ Eli Diaz
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ Eli Diaz
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
Chhom Karath
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
Dvst
DvstDvst
Dvst
hahaa225
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
Array Programs.pdf
Array Programs.pdfArray Programs.pdf
Array Programs.pdf
RajKamal557276
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointersvinay arora
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
Export Promotion Bureau
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
Prof. Dr. K. Adisesha
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacionJeff Tu Pechito
 

Similar to Cpd lecture im 207 (20)

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Arrays
ArraysArrays
Arrays
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++
 
Ds
DsDs
Ds
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Dvst
DvstDvst
Dvst
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
Array Programs.pdf
Array Programs.pdfArray Programs.pdf
Array Programs.pdf
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
C Programming
C ProgrammingC Programming
C Programming
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 

Recently uploaded

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
ShivajiThube2
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 

Recently uploaded (20)

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 

Cpd lecture im 207

  • 1. D e p a r t m e n t o f M e t a l l u r g i c a l E n g i n e e r i n g N E D U n i v e r s i t y Computer Programming Syed Muhammad Tanveer IM-207
  • 2. 1
  • 3. 2 #include<stdio.h> #include<conio.h> #include<string.h> void main(void) { clrscr(); int a; char ch[80]; printf("Enter a string: "); gets(ch); printf("n"); int b=strlen(ch); for(a=0;a<b;a++) { if (ch[a]>64&&ch[a]<91) ch[a]=ch[a]+32; else if (ch[a]>96&&ch[a]<123) ch[a]=ch[a]-32; } puts(ch); printf("nTotal words =%dn",b); getch(); } #include<stdio.h> #include<conio.h> void main(void) { int a,b; clrscr(); printf("enter a number: "); scanf("%d",&a); if (a%2==0) printf(" number is evenn "); else printf("number is oddn"); for (b=1;b<=10;b++) printf("%d x %d = %dn",a,b,a*b); getch(); } /* Assigment # 3 */ #include<stdio.h> #include<conio.h> void main(void) { int a,b; char ch= 'e'||'o'; clrscr(); printf("enter a number : "); scanf("%c",&ch); for(a=1;a<=10;a++) { if (ch=='e') for(b=1;b<=10;b++) { if (a%2==0) printf("%d x %d = %dn",a,b,a*b); } else if (ch=='o') for (b=1;b<=10;b++) { if (a%2==1) printf("%d x %d = %dn",a,b,a*b); } } /* Assignment # 3 */ #include<stdio.h> #include<conio.h> void main(void) { int a,b; char ch; clrscr(); printf("Press e or o : "); scanf("%c",&ch); switch (ch) { case 'e': for(a=1;a<=10;a++) { if (a%2==0) for (b=1;b<=10;b++) printf("t%d x %d = %dn",a,b,a*b); } break; case 'o': for(a=1;a<=10;a++) {
  • 4. 3 getche(); } if (a%2!=0) for (b=1;b<=10;b++) printf("t%d x %d = %dn",a,b,a*b); } break; default: printf("Error...nPlease pressn e tables of even numbersnORn o for tables of odd numbers "); break; } getche(); } #include<stdio.h> #include<stdlib.h> #include<conio.h> void main(void) { int a,b; clrscr(); for(a=1,b=1;a=5,b<=10;a++,b++) { textcolor(1); textbackground(4); cprintf("%d x %d = %d",a,b,a*b); printf("n"); } gotoxy(30,10); printf(“I m Here “); getche(); } #include<stdio.h> #include<conio.h> #include<string.h> void main(void) { clrscr(); int a; char ch[80]; printf("Enter a string: "); gets(ch); printf("n"); int slen=strlen(ch); for(a=0;a<slen;a++) { if (ch[a]=='e'||ch[a]=='a'||ch[a]=='o'||ch[a]=='u'|| ch[a]=='i') printf("%c",ch[a]-32); else printf("%c",ch[a]); } getch(); } #include<stdio.h> #include<conio.h> #include<string.h> void main(void) { clrscr(); int i,j,slen,temp; char A[]="muprteco"; slen=strlen(A); printf("Enter element in arrayn"); for(i=0;i<slen;i++) { printf("Alphabet %d = %c",i+1,A[i]); printf("n"); } #include<stdio.h> #include<conio.h> void main() { clrscr(); int a[100],n,i,beg,end,mid,item; printf("n------- BINARY SEARCH ------- nn"); printf("Enter No. of Elements= "); scanf("%d",&n); printf("nEnter Elements in Sorted Order=n"); for(i=1;i<=n;i++) scanf("%d",&a[i]); printf("nEnter Item you want to
  • 5. 4 printf("n Element enter by you is : n"); for(i=0;i<slen;i++) printf("%cn",A[i]); for(i=0;i<slen;i++) { for(j=i+1;j<slen;j++) if (A[i]<A[j]) { temp=A[i]; A[i]=A[j]; A[j]=temp; } printf("%ct",A[i]); } getch(); } Search= "); scanf("%d",&item); beg=1; end=n; mid=(beg+end)/2; while(beg<=end && a[mid]!=item) { if(a[mid]<item) beg=mid+1; else end=mid-1; mid=(beg+end)/2; } if(a[mid]==item) printf("nData is Found at Location : %d",-- mid); else printf("Data is Not Found"); getch(); } #include<stdio.h> #include<conio.h> main(){ const int a=2, b=0; int c=0; clrscr(); printf("Value of a = %d",a*4); c = a*4; printf("Value of a = %d",c); getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int a=2; const int b=2; printf("%d * %d = %d",a,b,a*b); /*b++; b is constant , b++ error */ getch(); } #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> void main(void) { clrscr(); int a,count=0,cons=0,space=0; char ch[80]; printf("Enter a string: "); gets(ch); int b=strlen(ch); for(a=0;a<b;a++) { if (isspace(ch[a])) space++; else if (ch[a]=='e' || ch[a]=='a'|| ch[a]=='o'|| ch[a]=='u' || ch[a]=='i') /* IMPORTANT FUNCTION QUESTION */ #include<stdio.h> #include<conio.h> int input(void); void main() { clrscr(); int num=input(); printf("nReturned Value =%d",num); getch(); } int input (void) { int a,b; printf("enter first number : "); scanf("%d",&a); printf("enter second number : "); scanf("%d",&b); float c=(float) a/b;
  • 6. 5 count++; else if (ch[a]!=' ') cons++; } printf("Total Character=%dtVowels=%dtConsonant=%dtSpace=%d", b-space,count,cons,space); getch(); } printf("ntt%d divided by %d= %.3f",a,b,c); return (a-b); } /* Post-fix & Pre-fix Decreament */ #include<stdio.h> #include<conio.h> void main(void) { clrscr(); printf("ttPost-fix & Pre-fix Decreamentn"); int x=10,y=20,z=30,a=40,b=50,c=60,e=80,d=70,f=90; printf("t%d and %dn",x,x); printf("t%d and %dn",y,y--); printf("t%d and %dn",z,--z); printf("t%d and %dn",a--,a); printf("t%d and %dn",b--,b--); printf("t%d and %dn",c--,--c); printf("t%d and %dn",--d,d); printf("t%d and %dn",--e,e--); printf("t%d and %dn",--f,--f); getch(); } /* Post-fix & Pre-fix Increament */ #include<stdio.h> #include<conio.h> void main(void) { clrscr(); printf("ttPost-fix & Pre-fix Increamentn"); int x=10,y=20,z=30,a=40,b=50,c=60,e=80,d=70,f=90 ; printf("t%d and %dn",x,x); printf("t%d and %dn",y,y++); printf("t%d and %dn",z,++z); printf("t%d and %dn",a++,a); printf("t%d and %dn",b++,b++); printf("t%d and %dn",c++,++c); printf("t%d and %dn",++d,d); printf("t%d and %dn",++e,e++); printf("t%d and %dn",++f,++f); getch(); } #include<stdio.h> #include<conio.h> #include<string.h> main() { int a[10][10]; int b[10][10]; int i,j,k,c[10][10],r1,c1,r2,c2,sum=0; clrscr(); printf("ttMultiplication of Two Matricesn"); /*FOR MATRICS A */ printf("nMatrics A"); printf("nEnter No of Row :"); scanf("%d",&r1); printf("nEnter No of Column :"); scanf("%d",&c1); for(i=0;i<r1;i++) #include<stdio.h> #include<conio.h> void main(void) { clrscr(); char ch; int i,j,n,temp; int A[10]; printf("Enter the no of element:"); scanf("%d",&n); printf("Enter element in arrayn"); for(i=0;i<n;i++) { printf("Element %d is ",i+1); scanf("%d",&A[i]); } printf("n Element enter by you is :
  • 7. 6 for( j=0;j<c1;j++) { printf("nEnter A[%d][%d] : ",i,j); scanf("%d",&a[i][j]); } for(i=0;i<r1;i++) { printf("n"); for(j=0;j<c1;j++) printf("%dt",a[i][j]); } printf("n"); /*FOR MATRICS B */ printf("nMatrics B"); printf("nEnter No of Row :"); scanf("%d",&r2); printf("nEnter No of Column :"); scanf("%d",&c2); for(i=0;i<r2;i++) for( j=0;j<c2;j++) { printf("nEnter b[%d][%d] : ",i,j); scanf("%d",&b[i][j]); } for(i=0;i<r2;i++) { printf("n"); for( j=0;j<c2;j++) printf("%dt",b[i][j]); } getch(); } printf("nPress Enter... "); clrscr(); if (r1==c2) { /*FOR MATRICS C */ printf("nMatrics c=a*bn"); for(i=0;i<r1;i++) for(j=0;j<c2;j++) { sum=0; for (k=0;k<c2;k++) sum=sum+a[i][k]*b[k][j]; c[i][j]=sum; } for(i=0;i<r1;i++) { for( j=0;j<c2;j++) printf("%dt",c[i][j]); printf("n"); } } else printf("nCould Not Multiply because Row of b != Column of b "); n"); for(i=0;i<n;i++) { printf("%dn",A[i]); } printf("If you want to sort in ascending ordertpress a tttOrnIf you want to sort in descending ordertpress bnt"); ch=getche(); if (ch=='a') { for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if (A[i]>A[j]) { temp=A[i]; A[i]=A[j]; A[j]=temp; } } printf("t%dt",A[i]); } } else if (ch=='b') for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if (A[i]<A[j]) { temp=A[i]; A[i]=A[j]; A[j]=temp; } } printf("t%dt",A[i]); } getche(); }
  • 8. 7 getch(); } #include<stdio.h> #include<conio.h> void power(int a,int b); void main() { clrscr(); int a,b; printf("Enter a number "); scanf("%d",&a); printf("%d ki power ",a); scanf("%d",&b); power(a,b); getch(); } void power(int a, int b) { long int e,c; e=a; for (int s=1;s<b;s++) e=e*a; printf("t=%ld",e); int i,n; printf("nSquare of "); for (i=1;i<=a;i++) c=a*a; printf("%d is %ld",a,c); } #include<stdio.h> #include<conio.h> void main(void) { int a,b; char c; do { clrscr(); printf("enter a number: "); scanf("%d",&a); for (;a<=b;a++) { if (a%2==0) for (b=1;b<=10;b++) printf("%d x %d = %dn",a,b,a*b); } c= getche(); } while (c=='f' || c =='F'); getch(); }
  • 9. 8 #include<stdio.h> #include<conio.h> #include<string.h> void main(void) { clrscr(); int a,b; char str[50]; printf("Enter a string:t"); gets(str); strrev(str); printf("%s",str); a=strlen(str); b=a; printf("Reverse string:t"); while (b>=0) { printf("%c",str[b]); b--; } getch(); } #include<stdio.h> #include<conio.h> void main(void) { int a,b; clrscr(); for(b=1;b<=10;b++) { for(a=1;a<=10;a++) printf("t%d",b*a); printf("n"); } getche(); } #include<stdio.h> #include<conio.h> void main(void) { int num =20; clrscr(); /*((num%2==0)? 1:0); */ ((num%2==1)?printf("nEven"):printf("nOdd")); getch(); } #include<stdio.h> #include<conio.h> void main(void) { char c =65; clrscr(); printf("character =%c, Its code= %d",c,c); printf("nTanveer "Raza""); getch(); } #include<stdio.h> #include<conio.h> //#include<string.h> //void printmsg(void); void printmsg(void) { printf("NED University of Engg. & Tech."); printf("n Department of Metallurgical engg."); #include<stdio.h> #include<conio.h> main() { int num[2][2]; int i,j; clrscr(); for(i=0;i<2;i++) for(j=0; j<2; j++) {
  • 10. 9 } main(){ clrscr(); printmsg(); getch(); } printf("enter number :"); scanf("%d",&num[i][j]); } clrscr(); for(i=0;i<2;i++) { for(j=0;j<2; j++) printf(" %dt",num[i][j]); printf("n"); } getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int a=21,e=0,o=0; while(a<=50) { if (a%2==0) e=e+a; else o=o+a; a++; } printf("Sum of Odd Numbers from 21-50=t%d",o); printf("nSum of Even Numbers from 21- 50=t%d",e); getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int c=0; char ch; while((ch=gethe())!=’r’) { c++; if (ch==’a’) a++; else if (ch==’e’) e++; else if (ch==’u’) u++; else if (ch==’o’) o++; else if (ch==’i’) i++; } printf(“nCharacter=%dnAs=%dnEs=%dnIs=%dnOs= %d nUs=%d”,c,a,e,i,o,u); getch(); } #include<stdio.h> #include<conio.h> #include<string.h> main(){ char str[20]; int len; clrscr(); printf("Enter a string :"); scanf("%[^n]s",str); len = strlen(str); #include<stdio.h> #include<conio.h> main(){ clrscr(); char name[30]; //="Metallurgy"; int i=0; while(name[i]!='o') { //gotoxy(30,10); printf("%c",name[i]);
  • 11. 10 printf("nLength of string = %d",len); getch(); } i++; } //scanf("%s",name); //gets(name); //puts(name); //printf("%s",name); getch(); } #include<stdio.h> #include<conio.h> void main(void) { int a,b; char c; //int a,b; do { clrscr(); scanf("%d%d",&a,&b); //while (a>1,b<=10) //for(;a<=100;a++) //for (b=25;a<=25,b>=1;a++,b--) { printf("%d + %d = %dn",a,b,a+b); a--,b++; //printf("%d",a); //printf("%d %dn",a,b); getche(); } /*printf("Engr. Syed Muhammad Tanveern");*/ //printf("tProud to be a "Pakistani""); } while (c=='f'); getche(); } #include<stdio.h> #include<conio.h> #include<string.h> main() { clrscr(); int i,j,A[2][2]; int max_num; for(i=0;i<2;i++) for( j=0;j<2;j++) { printf("nEnter A[%d][%d] : ",i,j); scanf("%d",&A[i][j]); } for(i=0;i<2;i++) { printf("n"); for(j=0;j<2;j++) printf("%dt",A[i][j]); } max_num=A[0][0]; for (i=0;i<2;i++) for( j=0;j<2;j++) { printf("%dt",A[i][j]); if (A[i][j]>=max_num) max_num=A[i][j]; } printf("nMaximun number = %d",max_num); getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); char ch[60]="Mike"; sizeof(ch); printf("nsize of ch = %d",sizeof (ch)); getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int max_num,a,count=0; int arr[10]={10,20,30,30,30,40,50,40,50,50}; max_num=arr[0]; for (a=0;a<10;a++) { printf("%dt",arr[a]); if (arr[a]>=max_num)
  • 12. 11 max_num=arr[a]; count++; } printf("Maximun number = %d times=%d",max_num,-- count); getch(); } #include<stdio.h> #include<conio.h> void main(void) { int a,b; clrscr(); for (a=1;a<=7;a++) { for (b=1;b<=a;b++) if (b%2==1 && a%2==1) printf("%dt",b); printf("n"); } getch(); } #include<stdio.h> #include<conio.h> #include<string.h> void main(void) { clrscr(); int a,b; char str[50]; printf("Enter a string...."); gets(str); printf("n"); a=strlen(str); for (b=a;b>=0;b--) printf("%c",str[b]); getch(); }
  • 13. 12 #include<stdio.h> #include<conio.h> #include<string.h> void main(void) { clrscr(); int a,b; char ch[80],c='w'; printf("Enter a string: "); gets(ch); b=strlen(ch); for(a=0;a<b;a++) { if (ch[a]==c) printf("%c",'e'); else printf("%c",ch[a]); } printf("nTotal words =%dn",b); getch(); } #include<stdio.h> #include<conio.h> void main (void) { clrscr(); int a=4,*b; b=&a; printf("Value of a=%d and its address=%un",a,&a); printf("Value of b=%d and its address=%un",*b,b); printf("value of a=%d and b=%d",a,*b); getch(); } #include<stdio.h> #include<conio.h> #include<string.h> void main(void) { clrscr(); int a,b; char ch[80]; printf("Enter a string: "); gets(ch); printf("nCharcter ASCII Equivalentn "); b=strlen(ch); for(a=0;a<b;a++) { printf("%c t %d",ch[a],ch[a]); printf("n"); } getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int a,count=0; printf("Enter a number : "); scanf("%d",&a); for (int i=1;i<=a;i++) { if (a%i==0) count++; } if (count==2) printf("Number is Prime"); else printf("Not a Prime Number"); getch(); } /* SWAP THE VALUES BETWEEN 2INTEGER #include<stdio.h>
  • 14. 13 VARIABLES */ #include<stdio.h> #include<conio.h> void readint (int *a,int *b); void swap (int *a,int *b); int main(void) { clrscr(); int num1,num2; readint(&num1,&num2); printf("Before swapping num1=%d and num2=%d n",num1,num2); swap(&num1,&num2); printf("After Swapping num1=%d and num2=%dn",num1,num2); getch(); return 0; } void readint(int *a,int *b) { printf("Enter first Integer number :"); scanf("%d",a); printf("Enter second integer number :"); scanf("%d",b); } void swap(int *a,int *b) { int temp; temp=*a; *a=*b; *b=temp; } #include<conio.h> #include<stdlib.h> void main(void) { clrscr(); int a=15; printf(“a=%d and it equivalent octal =%o”,a,a); printf(“a=%d and it equivalent hexa =%x”,a,a); getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int a,b; float per=0; printf("tttThis Program Calculate Percentage & Graden"); printf("Enter Obtained Marks:"); scanf("%d",&a); printf("Enter Total Marks:"); scanf("%d",&b); per=((float)a/b)*100; printf("Percentage=%.2f%n",per); if (per>60 && per<70) printf("Grade B"); else if (per>70 && per<80) printf("Grade A"); else if (per>80 && per<=100) printf("Grade A-one"); else if (per>50 && per<60) printf("Pass"); else printf("Fail"); /* swaps the values between 2 integer variables */ #include <stdio.h> #include<conio.h> void swap (int a, int b); main (void ) { int num1=40,num2=50; clrscr(); printf("before swapping num1= %d, num2=%dn",num1,num2); swap(num1,num2); getch(); } void swap (int a, int b) { int temp; temp=a; a=b; b=temp; printf("nAfter swapping num1= %d, num2=%dn",a,b); return; }
  • 15. 14 getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int i,j,temp,A[10]={78,45,9,11,12,2,100,4,6,5}; printf("Elemnts of Array In Asecending Ordern"); for(i=0;i<10;i++) { for(j=i+1;j<10;j++) if (A[i]>A[j]) { temp=A[i]; A[i]=A[j]; A[j]=temp; } printf("%dt",A[i]); } getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int a=1;b=0; while(a<=10) { b=b+a; printf(“Sum of Number =%d n”,b); a++; } getch(); } #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int r,c,i,j,A[10][10],B[10][10],C[10][10]; printf("Enter number of row:"); scanf("%d",&r); printf("Enter number of Columns:"); scanf("%d",&c); printf("Matrix An"); for (i=0;i<r;i++) for (j=0;j<c;j++) { printf("Enter Element of A[%d][%d]=:",i,j); scanf("%d",&A[i][j]); } for (i=0;i<r;i++) { for (j=0;j<c;j++) printf("%dt",A[i][j]); printf("n"); } printf("Matrix Bn"); for (i=0;i<r;i++) for (j=0;j<c;j++) { printf("Enter Element of B[%d][%d]=:",i,j); scanf("%d",&B[i][j]); } for (i=0;i<r;i++) { for (j=0;j<c;j++) #include<stdio.h> #include<conio.h> void main(void) { clrscr(); int a=1;b=1; for (a=1;a<=10;a++) { for (b=1;b<=10;b++) printf(“%d t”,a*b); printf(“n”); } getch(); } #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); for (a=0;a<11;a++) { if (a==4 || a==7) continue; printf(“Value of a is %dn”,a); }
  • 16. 15 printf("%dt",B[i][j]); printf("n"); } printf("Matrix C=A+Bn"); for (i=0;i<r;i++) { for (j=0;j<c;j++) printf("%dt",A[i][j]+B[i][j]); printf("n"); } getch(); } for (a=0; ;a++) { printf(“Value of a is %dn”,a); if (a>5) break; } getch(); } #include<stdio.h> #include<conio.h> #include<string.h> void main (void) { clrscr(); char wwe; char ch; int i,j,n,temp; int A[10]; int x,y,slen,pemt; printf("For number's sorting press s nFor alphabetic sorting press pnYour Choicet"); scanf("%c",&wwe); switch (wwe) { case 's': printf("ttSortingn"); printf("Enter the no of element:"); scanf("%d",&n); printf("Enter element in arrayn"); for(i=0;i<n;i++) { printf("Element %d is ",i+1); scanf("%d",&A[i]); } printf("n Element enter by you is : n"); for(i=0;i<n;i++) { printf("%dn",A[i]); } printf("If you want to sort in ascending ordertpress anOrnIf you want to sort in descendingordertpress bnt"); printf("n"); ch=getch(); if (ch=='a') { for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if (A[i]>A[j])
  • 17. 16 { temp=A[i]; A[i]=A[j]; A[j]=temp; } } printf("t%dt",A[i]); } } else if (ch=='b') for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if (A[i]<A[j]) { temp=A[i]; A[i]=A[j]; A[j]=temp; } } printf("t%dt",A[i]); } break; case 'p': clrscr(); char Z[100]; printf("Enter a string:"); fflush(stdin); gets(Z); slen=strlen(Z); printf("Enter element in arrayn"); for(x=0;x<slen;x++) { printf("Alphabet %d = %c",x+1,Z[x]); printf("n"); } printf("n Element enter by you is : n"); for(x=0;x<slen;x++) { printf("%cn",Z[x]); } printf("If you want to sort in ascending ordertpress a nOrnIf you want to sort in descendingordertpress bnt"); printf("n"); ch=getch(); if (ch=='a') { for(x=0;x<slen;x++) { for(y=x+1;y<slen;y++) if (Z[x]>Z[y]) { pemt=Z[x];
  • 18. 17 Z[x]=Z[y]; Z[y]=pemt; } printf("t%ct",Z[x]); } } else if (ch=='b') { for(x=0;x<slen;x++) { for(y=x+1;y<slen;y++) { if (Z[x]<Z[y]) { pemt=Z[x]; Z[x]=Z[y]; Z[y]=pemt; } } printf("t%ct",Z[x]); } } break; } getche(); } #include<stdio.h> #include<conio.h> int inputnum(void) { int num; clrscr(); printf("Enter a Number :"); scanf("%d",&num); printf("n"); return num; } void table(void) { int num2; num2= inputnum(); for(int i=1; i<11; i++) { printf("%d x %d = %dn",num2,i,num2*i); } } void cont (void) { char ch; #include<stdio.h> #include<conio.h> void heading(void) { printf("NED university of Engg. & Tech.n"); printf("Department of Metallurgical Engg."); } void add(int a,int b) { //int num1=4, num2=6; printf("%d + %d = %d",a,b,a+b); } void table(int a) { //int num=2; clrscr(); for(int i=1; i<11; i++) printf("%d x %d = %dn",a,i,a*i); //getch(); }
  • 19. 18 do { clrscr(); table(); printf("n Press Y/y for Continue..... :"); ch=getche(); } while(ch=='Y' || ch=='y'); } #include<stdio.h> #include<ctype.h> #include<conio.h> #include<string.h> void main () { clrscr(); int i=0; char str[]="CS6"; int slen=strlen(str); while (i<slen) { if (isalpha(str[i])) printf ("character %c is alphabeticn",str[i]); else printf ("character %c is not alphabeticn",str[i]); i++; } getch(); } #include<ctype.h> #include<stdio.h> #include<conio.h> #include<string.h> void main(void) { clrscr(); char arr[100]; printf("Type: "); gets(arr); int isdigit,slen=strlen(arr); for (int i=0;i<slen;i++) { printf("n%d word is a : ",i+1); if (isdigit(arr[i])) printf("Digit"); else printf("Character"); } getch(); } #include<stdio.h> #include<conio.h> void main (void) { clrscr(); int vowel=0,c=0; char ch; while((ch=getch())!=’r’) { c++; if (ch==’a’ || ch==’u’ || ch==’o’ || ch==’i’ || ch==’e’ ) vowel++; } #include<stdio.h> #include<conio.h> void main (void) { clrscr(); int num=0,i=0; for ( ;num<=256;num++) { printf(“%d : %cn”,num,num); i++; if (i==24) printf(“Press any key to continue….”); getch();
  • 20. 19 printf(“Character=%dnVowel=%d”,c,vowel); getch(); } clrscr(); i=0; } getch(); } #include<stdio.h> #include<conio.h> void main (void) { clrscr(); int id; printf(“Enter a number less than 4:”); scanf(“%d”,&id); switch (id) { case 1: printf(“A”); break(); case 1: printf(“B”); break(); case 1: printf(“C”); break(); defaut: printf(“Not Found”); break(); } getch(); } #include<stdio.h> #include<conio.h> void main (void) { clrscr(); int a=1,b=0; while (a<=10) { b=b+a; printf(“nsum of Number %d + %d=%d”,a,a+1,b); a++; } getch(); } #include<stdio.h> #include<conio.h> void power(int a,int b); void main() { clrscr(); int a,b; printf("Enter a number "); scanf("%d",&a); printf("%d ki power ",a); scanf("%d",&b); power(a,b); printf("nSum %dn",a+b); printf("Subtraction %dn",a-b); printf("Multiplication %dn",a*b); printf("Divison %.3fn",(float)a/b); printf("Remiander %dn",a%b); getch(); } void power(int a, int b) { long int e,c;
  • 21. 20 e=a; for (int s=1;s<b;s++) e=e*a; printf("t=%ld",e); int i,n; printf("nSquare of "); for (i=1;i<=a;i++) c=a*a; printf("%d is %ld",a,c); }