The document contains source code for multiple C programming assignments. The code includes programs to:
1) Convert a string to uppercase/lowercase, count characters, vowels, consonants, and spaces.
2) Perform binary search on an array.
3) Multiply two matrices.
4) Sort an array in ascending and descending order.
5) Calculate power of a number using recursion.
6) Print tables for multiplication from 1 to 10.
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
Ex.1 Write a program to print the following pattern
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Ex.2 Write a program to find bigger of three integers.
Ex.3 Write a program to calculate GCD between two numbers.
Ex.4 Write a program to find transpose of matrix.
Ex.5 Write a program which deletes an element from an array & display all other elements.
Ex.6 Write a program to calculate XA+YB where A & B are matrix & X=2, Y=3.
Ex.7 Write a program to calculate the total amount of money in the piggy bank, given that coins of Rs.10, Rs.5, Rs.2, RS.1.
& many more.....
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
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];
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); }