Monday 16 September 2013

Object Oriented Programming Language using C++ Most Important Questions on Internal Exam HNGU

Filled under:


Posted By New19:21

Thursday 9 May 2013

Sortcut key in Turbo C++

Filled under:


ALT-ENTER              :           Go full screen and back
ALT-PAUSE              :           Pause DOSBOX
CTRL-F1                    :           Start the keymapper
CTRL-F4                    :           Upadete directory cache for all drive! Swap mounted disk-image
CTRL-ALT-F5  :                     Start/Stop creating a movie of the wave file.
CTRL-F5                    :           Save a screenshot
CTRL-F6                    :           Start/Stop recording sound output to a wave file
CTRL-ALT-F7  :                     Start/Stop recording of OPL commands.
CTRL-ALT-F8  :                     Start/Stop the recording of raw MIDI commands.
CTRL-F7                    :           Decrease frame skip.
CTRL-F8                    :           Increase framskip.
CTRL-F9                    :           Kill DOSBox.
CTRL-F10                 :           Capture/Release the mouse.
CTRL-F11                  :           Slow down emulation (Decrease DOSBox Cycles).
CTRL-F12                 :           Speed up emulation (Increase DOSBox Cycle).
ALT-F12                     :           Unlock speed (turbo button/fast forward).


-------------------------------------------
ALT + Enter   :                        Full Screen

Posted By New11:00

Wednesday 8 May 2013

C 52 Practical Programs

Filled under:

Fundamental of Programming Language 'C' 52 Practical Programs
 
Pr-1- write a c program to display “hello computer” on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
printf(“hello computer”);
}
Out put:
hello computer

Pr-2- write a c program to print roll no, name, address.
#include<stdio.h>
#include<conio.h>
void main()
{
printf(“ROLL NO=1”);
printf(“NAME=SAMARTH”);
printf(“ADDRESS= SAMARTH BCA COLLEGE \n SAMARTH CAMPUS \n HAJIPUR \n HIMMATNAGAR”);
}
Output:
ROLL NO=1
NAME=SAMARTH
ADDRESS= SAMARTH BCA COLLEGE
SAMARTH CAMPUS
HAJIPUR
HIMMATNAGAR

Pr-3- write a C program to find the area of circle using the formula Area=PI*r*r.
#include<stdio.h>
#include<conio.h>
void main()
{
float pi=3.14;
float r,area;
printf("ENTER THE VALUE OF r=");
scanf("%f",&r);
area=pi*r*r;
printf("AREA=%f",area);
getch();
}
Output:
ENTER THE VALUE OF r=5
AREA=78.500000

Pr-4- write a C program to find the area of rectangle ,cube and tringle.( formula are: rectangle=l*b*h, tringle=(l*b)*0.5, cube=l*l*l)
#include<stdio.h>
#include<conio.h>
void main()
{
float t;
int l,b,h,r,c;
clrscr();
printf("\nENTER THE VALUE OF l=");
scanf("%d",&l);
printf("\nENTER THE VALUE OF b=");
scanf("%d",&b);
printf("\nENTER THE VALUE OF h=");
scanf("%d",&h);
r=l*b*h;
c=l*l*l;
t=(l*b)*0.5;
printf("\n RECTANGLE=%d",r);
printf("\n CUBE=%d",c);
printf("\n TRIANGLE=%f",t);
getch();
}
Output:
ENTER THE VALUE OF l=5
ENTER THE VALUE OF b=3
ENTER THE VALUE OF h=2
RECTANGLE=30
CUBE=125
TRIANGLE=7.500000

Pr-5- write a C program to find area and volume of sphere. formulas are area=4*pi*r*r, volume=4/3*pi*r*r*r.
#include<stdio.h>
#include<conio.h>
void main()
{
float pi=3.14;
float area,vol;
int r;
clrscr();
printf("\nENTER THE VALUE OF r=");
scanf("%d",&r);
area=4*pi*r*r;
vol=4/3*pi*r*r*r;
printf("\nAREA=%f",area);
printf("\nVOLUME=%f",vol);
getch();
}
Output:
ENTER THE VALUE OF r=5
AREA=314.000000
VOLUNE=392.500000

Pr-6-write a c program to evaluate simple interest I=P*R*N/100.
#include<stdio.h>
#include<conio.h>
void main()
{
float p, r,n,i;
clrscr();
printf(“enter p=”);
scanf(“%f”,&p);
printf(“enter r=”);
scanf(“%f”,&r);
printf(“enter n=”);
scanf(“%f”,&n);
i=(p*r*n)/100;
printf(“intrest=%f”,i);
getch();
}
Output:
enter p=100
enter r=6
enter n=3
intrest=18.000000

Pr-7-enter kilometer and convert it into meter,feet,inches,centimeter.
#include<stdio.h>
#include<conio.h>
void main()
{
long int km,f,m,cm;
float i;
clrscr();
printf("enter kilometer");
scanf("%ld",&km);
m=km*1000;
f=km*32748;
i=km*3448.38;
cm=km*100000;
printf("\n meter=%ld",m);
printf("\n feet=%ld",f);
printf("\n inch=%f",i);
printf("\n centimeter=%ld",cm);
}
Output:
enter kilometer2
meter=2000
feet=65496
inch=6896.759766
centimeter=200000

Pr-8-interchange two value.
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,t;
clrscr();
printf("\n enter n1:");
scanf("%d",&n1);
printf("\n enter n2:");
scanf("%d",&n2);
t=n1;
n1=n2;
n2=t;
printf("new n1=%d \n",n1);
printf("new n2=%d \n",n2);
}
Output:
enter n1:22
enter n2:33
new n1=33
new n2=22

pr-9-to convert feranheit in to centigrade, formula c=(f-32)/1.8.
#include<stdio.h>
#include<conio.h>
void main()
{
int f;
float c;
clrscr();
printf("enter the value of f:");
scanf("%d",&f);
c=(f-32)/1.8;
printf("\n centigrade=%f",c);
}
Output:
enter the value of f:55
centigrade=12.777778

pr-10- summation,subtraction, multiplication, division using arithmetic operator.
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,a,s,m;
float d;
clrscr();
printf("\n enter n1:");
scanf("%d",&n1);
printf("\n enter n2:");
scanf("%d",&n2);
a=n1+n2;
s=n1-n2;
m=n1*n2;
d=n1/(float)n2;
printf("\n addition=%d",a);
printf("\n subtraction=%d",s);
printf("\n multiplication=%d",m);
printf("\n division=%f",d);
}
Output:
enter n1:20
enter n2:5
addition=25
subtraction=15
multiplication=100
division=4.000000

pr-11-enter days and convert it into years,month, and reminder days.
#include<stdio.h>
#include<conio.h>
void main()
{
int d,y,m,rd;
clrscr();
printf("enter days:");
scanf("%d",&d);
y=d/365;
m=(d-(365*y))/30;
rd=(d-(365*y)-(m*30));
printf("year=%d \n",y);
printf("month=%d \n",m);
printf("reminder day=%d \n",rd);
}
Output:
enter days:400
year=1
month=1
reminder day=5

pr-12-to find largest value from three numbers using conditional operator.
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,n3;
clrscr();
printf("\n enter n1:");
scanf("%d",&n1);
printf("\n enter n2:");
scanf("%d",&n2);
printf("\n enter n3:");
scanf("%d",&n3);
(n1>n2)?((n1>n3)?printf("%d is max",n1):printf("%d is max",n3)):((n2>n3)?printf("%d is max",n2):printf("%d is max",n3));
}
Output:
enter n1:22
enter n2:66
enter n3:55
66 is max

pr-13-to find largest value from three numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,n3;
clrscr();
printf("\n enter n1:");
scanf("%d",&n1);
printf("\n enter n2:");
scanf("%d",&n2);
printf("\n enter n3:");
scanf("%d",&n3);
if(n1>n2)
{
if(n1>n3)
{
printf("max=%d",n1);
}
else
{
printf("max=%d",n3);
}
}
else
{
if(n2>n3)
{
printf("max=%d",n2);
}
else
{
printf("max=%d",n3);
}
}
}
Output:
enter n1:88
enter n2:99
enter n3:77
max=99

pr-14 given number is positive or negative or zero.
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("\n enter n:");
scanf("%d",&n);
if(n>0)
{
printf("no is positive");
}
else if(n<0)
{
printf("no is negative");
}
else
{
printf("no is zero");
}
}
Output:
(1) enter n:8
no is positive
(2)enter n:-8
no is negative
(3)enter n:0
no is zero

pr-15entered character is capital or small or digit .
#include<stdio.h>
#include<conio.h>
void main()
{
char c;
clrscr();
printf("enter one character=");
c=getchar();
if(c>='A' && c<='Z')
{
printf("given character is an uppercase");
}
else if(c>='a' && c<='z')
{
printf("given character is an small case");
}
else if(c>='0' && c<='9')
{
printf("given character is digit");
}
else
{
printf("given character is special character");
}
}
Output:
(1)enter one character=a
given character is an small case
(2) enter one character=A
given character is an uppercase
(3) enter one character=9
given character is digit
(4)enter one character=#
given character is special character

pr-16 print 1 to 7 and relatively Sunday to Saturday.
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("\n enter n:");
scanf("%d",&n);
switch(n)
{
case 1:printf("sunday");
break;
case 2:printf("monday");
break;
case 3:printf("tuesday");
break;
case 4:printf("thrusday");
break;
case 5:printf("friday");
break;
case 6:printf("saturday");
break;
case 7:printf("sunday");
break;
default:printf("invalid day of number");
}
}
Output:
(1) enter n:1
sunday
(2) enter n:6
saturday
(3)enter n:55
invalid day of number

PR-17 //this is program for finding max and min from given 10 numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,max,min;
clrscr();
for(i=1;i<=10;i++)
{
printf("enter no %d=",i);
scanf("%d",&n);
if(i==1)
{
max=n;
min=n;
}
else
{
if(max<n)
{
max=n;
}
if(min>n)
{
min=n;
}
}
}
printf("max=%d\n",max);
printf("min=%d\n",min);
}
out put:
enter no 1=12
enter no 2=23
enter no 3=222
enter no 4=34
enter no 5=45
enter no 6=56
enter no 7=67
enter no 8=66
enter no 9=77
enter no 10=78
max=222
min=12

18//this is program for sum of digit.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,x,s=0;
clrscr();
printf("enter no=");
scanf("%d",&n);
while(n!=0)
{
x=n%10;
s=s+x;
n=n/10;
}
printf("sum of digit=%d\n",s);
}
out put:
enter no=1234
sum of digit=10

19//this is program for finding sum of first 100 odd and even no.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,o=0,e=0;
clrscr();
for(i=1;i<=200;i++)
{
if(i%2==0)
{
e=e+i;
}
else
{
o=o+i;
}
}
printf("sum of odd no=%d\n",o);
printf("sum of even no=%d\n",e);
}

out put:
sum of odd no=10000
sum of even no=10100

20//this is program for display 25 fibonnaci no.
#include<stdio.h>
#include<conio.h>
void main()
{
long int a=0,b=1,c,i;
clrscr();
printf("fibonnaci series ::\n");
printf("%ld\n",a);
printf("%ld\n",b);
for(i=3;i<=25;i++)
{
c=a+b;
printf("%ld\n",c);
a=b;
b=c;
}

out put:
fibonnaci series ::
0
1
123581321345589144233377610987159725844181676510946177112865746368

21 //This is program for accepted no prime or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int no,i;
clrscr();
printf("Enter number:");
scanf("%d",&no);
for(i=2;i<=no;i++)
{
if(no%i==0)
break;
}
if(i==no)
printf("this number is prime \n");
else
printf("this number is not prime \n");
}
Out put:
Enter number:23
this number is prime
Enter number:22
this number is not prime

22 //this is programme for to display first 100 prime nos.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,no=0;
clrscr();
for(i=0;no!=100;i++)
{
for(j=2;j<=no;j++)
{
if(i%j==0)
break;
}
if(i==j)
{
printf("%d\n",i);
}
no++;
}
getch();
}

Out put:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

23//this is program for finding factorial of no.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,f=1;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
f=f*i;
}
printf("Factorial of  %d is %d\n",n,f);
}
Out put:
Enter No=5
Factorial of 5 is 120

24//this is program for accepted no and its reverse no.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,x,s=0;
clrscr();
printf("Enter No=");
scanf("%d",&n);
while(n!=0)
{
x=n%10;
s=s*10+x;
n=n/10;
}
printf("Reverse No=%d\n",s);
}

Out put:
Enter No=123
Reverse No=321

25//this is program for accepted no is pelindrom or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,x,s=0;
clrscr();
printf("Enter No=");
scanf("%d",&n);
m=n;
while(n!=0)
{
x=n%10;
s=s*10+x;
n=n/10;
}
if(m==s)
{
printf("%d is Pelindrom no\n",m);
}
else
{
printf("%d is not Pelindrom no\n",m);
}
}

Out put:
(1)Enter No=1234
1234 is not Pelindrom no

(2)Enter No=12321
12321 is Pelindrom no

26//this is program for converting decimal to binary.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=1,x,b=0;
clrscr();
printf("Enter Decimal No=");
scanf("%d",&n);
while(n!=0)
{
x=n%2;
s=s*10+x;
n=n/2;
}
while(s!=0)
{
x=s%10;
b=b*10+x;
s=s/10;
}
b=b/10;
printf("Binary No=%d\n",b);
}

Out put:
Enter Decimal No=10
Binary No=1010

27//this is program for converting decimal to octal.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=1,x,b=0;
clrscr();
printf("Enter Decimal No=");
scanf("%d",&n);
while(n!=0)
{
x=n%8;
s=s*10+x;
n=n/8;
}
while(s!=0)
{
x=s%10;
b=b*10+x;
s=s/10;
}
b=b/10;
printf("Octal No=%d\n",b);
}

Out put:
Enter Decimal No=10
Octal No=12

28//this is program for converting decimal to hexadecimal.
#include<stdio.h>
#include<conio.h>
void main()
{
int b[20],i,n,j;
clrscr();
printf("\n Enter Decimal number:");
scanf("%d",&n);
i=0;
while(n>0)
{
b[i]=n%16;
n=n/16;
i++;
}
printf("\n Hexadecimal number :");
for(j=i-1;j>=0;j--)
{
switch(b[j])
{
case 10:
printf("A");
break;
case 11:
printf("B");
break;
case 12:
printf("C");
break;
case 13:
printf("D");
break;
case 14:
printf("E");
break;
case 15:
printf("F");
break;
default:
printf("%d",b[j]);
}
}
}

Out put:
Enter Decimal number:2598
Hexadecimal number :A26

29//this is program for display first 5 armstrong number.
#include<stdio.h>
#include<conio.h>
void main()
{
int t,a=1,n=1,x,y,s;
clrscr();
printf("Armstrong No\n");
while(n<=5)
{
t=a;
s=0;
while(t!=0)
{
x=t%10;
y=t/10;
s=s+(x*x*x);
t=y;
}
if(a==s)
{
printf("%d\n",a);
n++;
}
a++;
}
}

Output:
Armstrong No
1
153
370
371
407

30//this is for arrange the accepted number in accending and decending order.
#include<stdio.h>
#include<conio.h>
void main()
{
int temp,i,j,no[10],n;
clrscr();
printf("\n Enter number:");
scanf("%d",&n);
for (i=0;i<n;i++)
{
printf("\n Enter number:");
scanf("%d",&no[i]);
}
//descending order
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(no[i]<no[j])
{
temp=no[i];
no[i]=no[j];
no[j]=temp;
}
}
}
printf("\n Descending no:");
for(i=0;i<n;i++)
{
printf("%d \n",no[i]);
}
//Ascending order
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(no[i]>no[j])
{
temp=no[i];
no[i]=no[j];
no[j]=temp;
}
}
}
printf("\n Ascending no:");
for(i=0;i<n;i++)
{
printf("%d\n",no[i]);
}
}
Out put:
Enter number:5
Enter number:23
Enter number:34
Enter number:3
Enter number:2
Enter number:55
Descending no:55
34
23
3
2
Ascending no:2
3
23
34
55

31//This is program for accepted string is pelindrom or not.
#include<stdio.h>
#include<conio.h>
void main()
{
char str[100],len,i;
clrscr();
printf("\n Enter any string:");
gets(str);
len=strlen(str)-1;
for(i=0;str[i]!='\0';i++,len--)
{
if(str[i]!=str[len])
break;
}
if(i==strlen(str))
printf("Entered string is pelindrom");
else
printf("Entered string is not pelindrom");
}

Out put:1
Enter any string:madam
Entered string is pelindrom
Out put:2
Enter any string:abscfe
Entered string is not pelindrom

32//this program for convert given line into uppercase or lowercase.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i;
char str[60],ch;
clrscr();
printf("Enter string:");
gets(str);
printf("\n====Menu====");
printf("\nPress U for upper case");
printf("\nPress L for lower case");
printf("\n Enter your choice-->");
ch=getchar();
printf("\n\n\n==>");
switch(ch)
{
case 'U':
case 'u':
for(i=0;str[i]!=NULL;i++)
{
putchar(toupper(str[i]));
}
break;
case 'L':
case 'l':
for(i=0;str[i]!=NULL;i++)
{
putchar(tolower(str[i]));
}
break;
default:
printf("\n your choice is wrong");
break;
}
getch();
}

Out put:1
Enter string:madam
====Menu====
Press U for upper case
Press L for lower case
Enter your choice-->u
==>MADAM

Out put:2
Enter string:MADAM
====Menu====
Press U for upper case
Press L for lower case
Enter your choice-->l
==>madam

33//This program for count no of words,character,line and spaces from given text.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,word,chr,line,space;
char str[100],ch='A';
clrscr();
word=chr=line=space=0;
word=line=1;
printf("Enter String:(Exit Press@:)");
for(i=0;ch!='@';i++)
{
ch=getchar();
str[i]=ch;
}
str[i]='\0';
for(i=0;str[i]!='@';i++)
{
if(str[i]== ' ')
space++;
if(str[i]=='\n')
line++;
if(str[i]== ' ' &&(  str[i-1]!=' ' && str[i-1]!='\n'))
word++;
if(str[i]!=' ' && str[i-1]!='\n' && str[i]=='\n')
word++;
chr++;
}
printf("\n space=%d",space);
printf("\n word=%d",word);
printf("\n line=%d",line);
printf("\n char=%d",chr);
}
Out put:
Enter String:(Exit Press@:)samarth bca collage
himmatnagar
@
space=2
word=5
line=3
char=32

34 //this program for to sort given string in asceding order.
#include<stdio.h>
#include<conio.h>
void main()
{
char str[30],ch;
int i,j;
clrscr();
printf("Enter String:");
gets(str);
for(i=0;str[i]!='\0';i++)
{
for(j=0;str[j]!='\0';j++)
{
if(str[i]<str[j])
{
ch=str[i];
str[i]=str[j];
str[j]=ch;
}
}
}
printf("\n\nAfter sorting Stringis: %s",str);
}

Out put:
Enter String:anfsgetrhdy
After sorting Stringis: adefghnrsty

35//This program is to prepare pay slip using following data.
#include<stdio.h>
#include<conio.h>
void main()
{
int da,hra,ma=300,pf,gross,net;
int basic;
clrscr();
printf("Enter Basic Salary:");
scanf("%d",&basic);
da=basic/10;
hra=(basic*(750/100))/100;
pf=(basic*(1250/100))/100;
gross=basic+da+hra+ma;
net=gross-pf;
printf("Your Gross Salary is:%d \n",gross);
printf("Your Net Salary is %d\n",net);
}

Output:
Enter Basic Salary:5000
Your Gross Salary is:5495
Your Net Salary is 5550

36 //This program for to read marks and your program will display grade.
#include<stdio.h>
#include<conio.h>
void main()
{
int marks;
clrscr();
printf("Enter Marks:");
scanf("%d",&marks);
if(marks>=80 && marks<=100)
{
printf("Distiction");
}
else if(marks>=60 && marks<=79)
{
printf("First Class");
}
else if(marks>=50 && marks<=59)
{
printf("Second Class");
}
else if(marks>=35 && marks<=49)
{
printf("Pass Class");
}
else if(marks<=34 && marks>=0)
{
printf("Fail");
}
}
Out put:
Enter Marks:23
Fail
Enter Marks:45
Pass Class
Enter Marks:77
First Class

37//This program is to display 1+1/2+1….n.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
float s=0;
clrscr();
printf("Enter No : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
s=s+(1.0/i);
}
printf("Ans=%f",s);
}

Output:
Enter No : 3
Ans=1.833333

38//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,c;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(r=1;r<=n;r++)
{
for(c=1;c<=n;c++)
{
if(c<=r)
{
printf("%d",c);
}
}
printf("\n");
}
}

Out put:
Enter No=5
1
12
123
1234
12345

39//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,c;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(r=1;r<=n;r++)
{
for(c=1;c<=n;c++)
{
if(c<=r)
{
printf("%d",r);
}
}
printf("\n");
}
}

Out put:
Enter No=4
1
22
333
4444

40//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,j;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(r=1;r<=n;r++)
{
for(j=r;j>=1;j--)
{
printf("%d",j%2);
}
printf("\n");
}
}

Out put:
Enter No=5
1
01
101
0101
10101

41//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,c;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(r=1;r<=n;r++)
{
for(c=n;c>=1;c--)
{
if(c<=r)
{
printf("%d ",r);
}
else
{
printf(" ");
}
}
printf("\n");
}
}

Out put:
Enter No=5
1
22                                                                Not Valid
333
4444
55555

42//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,c,t=1;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(r=1;r<=n;r++)
{
for(c=1;c<=n;c++)
{
if(c<=r)
{
printf("%d",t);
t++;
}
}
printf("\n");
}
}

Out put:
Enter No=4
1
23
456
78910

43//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,c;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(r=1;r<=n;r++)
{
for(c=1;c<=n;c++)
{
if(c<=r)
{
printf("*");
}
}
printf("\n");
}
}

Out put:
Enter No=5
*
**
***
****
*****

44//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,c;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(r=1;r<=n;r++)
{
for(c=n;c>=1;c--)
{
if(c<=r)
{
printf("* ");

}
else
{
printf(" ");
}
}
printf("\n");
}
}

Out put:
Enter No=5
*
**
***
****
*****

45//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,c,t=1;
clrscr();
printf("Enter No=");
scanf("%d",&n);
for(r=1;r<=n;r++)
{
for(c=n;c>=1;c--)
{
if(c<=r)
{
printf("%3d  ",t);
t++;
}
else
{
printf("   ");
}
}
printf("\n");
}
}

Out put:
Enter No=5
1
2    3
4    5     6                                    Not Valid
7     8    9   10
11   12   13   14   15

46//Write a program to display this output on the screen.
#include<stdio.h>
#include<conio.h>
void main()
{
char s[]="CPROGRAMMING";
int i,j,l;
clrscr();
l=strlen(s);
for(i=0;i<l;i++)
{
for(j=0;j<=i;j++)
{
printf("%c",s[j]);
}
printf("\n");
}
for(i=l-2;i>=0;i--)
{
for(j=0;j<=i;j++)
{
printf("%c",s[j]);
}
printf("\n");
}
}

Out put:
C
CP
CPR
CPRO
CPROG
CPROGR
CPROGRA
CPROGRAM
CPROGRAMM
CPROGRAMMI
CPROGRAMMIN
CPROGRAMMING
CPROGRAMMIN
CPROGRAMMI
CPROGRAMM
CPROGRAM
CPROGRA
CPROGR
CPROG
CPRO
CPR
CP
C

47//This program is to find maximum and minimum value from the givan array.

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],max,min,i,j;
clrscr();
for(i=0;i<5;i++)
{
printf("Enter Element =");
scanf("%d",&a[i]);
}
max=a[0];
min=a[0];
for(i=1;i<5;i++)
{
if(a[i]>max)
{
max=a[i];
}
if(a[i]<min)
{
min=a[i];
}
}
printf("Max=%d\n",max);
printf("Min=%d\n",min);
}

Output:
Enter Element =5
Enter Element =23
Enter Element =34
Enter Element =1
Enter Element =55
Max=55
Min=1

48//This program is to find the next minimum value from the given array.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],max,min,i,j,nm;
clrscr();
for(i=0;i<5;i++)
{
printf("Enter Element =");
scanf("%d",&a[i]);
}
max=a[0];
min=a[0];
for(i=1;i<5;i++)
{
if(a[i]>max)
{
max=a[i];
}
if(a[i]<min)
{
min=a[i];
}
}
printf("Max=%d\n",max);
printf("Min=%d\n",min);
nm=max;
for(i=0;i<5;i++)
{
if(a[i]>min && a[i]<nm)
{
nm=a[i];
}
}
printf("Next Min=%d\n",nm);
}

Output:
Enter Element =88
Enter Element =99
Enter Element =23
Enter Element =54
Enter Element =11
Max=99
Min=11
Next Min=23

49//This program is to input n and find out the sum, average, max, min, total even no and total odd no.(without use of array)
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,t,s=0,mx=0,mn=0,to=0,te=0;
float a;
clrscr();
printf("How many nos. you have to entered=");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter No=");
scanf("%d",&t);
s=s+t;
if(t>mx)
{
mx=t;
}
if(t<mn)
{
mn=t;
}
if(t%2==0)
{
te=te+t;
}
else
{
to=to+t;
}
}
a=s/(float)n;
printf("Sum=%d\n",s);
printf("Avg=%f\n",a);
printf("Max=%d\n",mx);
printf("Min=%d\n",mn);
printf("Sum of Odd No=%d\n",to);
printf("Sum of Even No=%d\n",te);
}

Output:
How many nos. you have to entered=5
Enter No=12
Enter No=34
Enter No=43
Enter No=23
Enter No=55
Sum=167
Avg=33.400002
Max=55
Min=0
Sum of Odd No=121
Sum of Even No=46

50//This program is to input n and find out the sum, average, max, min, total even no and total odd no.(using array)
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,t[20],s=0,mx=-32768,mn=32767,to=0,te=0;
float a;
clrscr();
printf("How many nos. you have to entered=");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter No=");
scanf("%d",&t[i]);
s=s+t[i];
if(t[i]>mx)
{
mx=t[i];
}
if(t[i]<mn)
{
mn=t[i];
}
if(t[i]%2==0)
{
te=te+t[i];
}
else
{
to=to+t[i];
}
}
a=s/(float)n;
printf("Sum=%d\n",s);
printf("Avg=%f\n",a);
printf("Max=%d\n",mx);
printf("Min=%d\n",mn);
printf("Sum of Odd No=%d\n",to);
printf("Sum of Even No=%d\n",te);
}

Output:
How many nos. you have to entered=5
Enter No=23
Enter No=34
Enter No=45
Enter No=12
Enter No=99
Sum=213
Avg=42.599998
Max=99
Min=12
Sum of Odd No=167
Sum of Even No=46

Pr-51 //This program is to display the two matrix on screen and perform the addition of two matrix and print on screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],d[3][3],r,c;
clrscr();
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("Enter Value for Matrix A=");
scanf("%d",&a[r][c]);
}
}
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("Enter Value for Matrix B=");
scanf("%d",&b[r][c]);
}
}
printf("\n\n\n<<MATRIX A>>\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("%3d",a[r][c]);
}
printf("\n");
}
printf("\n\n\n<<MATRIX B>>\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("%3d",b[r][c]);
}
printf("\n");
}
printf("\n\n<<ADDISION OF TWO MATRIX>>\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
d[r][c]=a[r][c]+b[r][c];
printf("%d ",d[r][c]);

}
printf("\n");
}
}
Output:
Enter Value for Matrix A=1
Enter Value for Matrix A=2
Enter Value for Matrix A=3
Enter Value for Matrix A=4
Enter Value for Matrix A=5
Enter Value for Matrix A=6
Enter Value for Matrix A=7
Enter Value for Matrix A=8
Enter Value for Matrix A=9
Enter Value for Matrix B=1
Enter Value for Matrix B=2
Enter Value for Matrix B=3
Enter Value for Matrix B=4
Enter Value for Matrix B=5
Enter Value for Matrix B=6
Enter Value for Matrix B=7
Enter Value for Matrix B=8
Enter Value for Matrix B=9
<<MATRIX A>>
1  2  3
4  5  6
7  8  9
<<MATRIX B>>
1  2  3
4  5  6
7  8  9
<ADDISION OF TWO MATRIX>>
246
8 10 12
14 16 18
52//This program is to display the two matrix on screen and perform the multiplication of two matrix and print on screen.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],d[3][3],r,c,k;
clrscr();
printf("MATRIX = A\n\n\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("Enter Value=");
scanf("%d",&a[r][c]);
}
}
printf("MATRIX B\n\n\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("Enter Value=");
scanf("%d",&b[r][c]);
}
}
printf("MATRIX MULTIPLICATION\n\n\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
d[r][c]=0;
for(k=0;k<3;k++)
{
d[r][c]=d[r][c]+(a[r][k]*b[k][c]);
}
}
}
printf("<<<MATRIX A\n\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("%3d",a[r][c]);
}
printf("\n");
}
printf("<<<MATRIX B\n\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("%3d",b[r][c]);
}
printf("\n");
}
printf("<<<MATRIX C\n\n");
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("%3d",d[r][c]);
}
printf("\n");
}
getch();
}
Output:
MATRIX = A
Enter Value=1
Enter Value=2
Enter Value=3
Enter Value=4
Enter Value=5
Enter Value=6
Enter Value=7
Enter Value=8
Enter Value=9
MATRIX B
Enter Value=9
Enter Value=8
Enter Value=7
Enter Value=6
Enter Value=5
Enter Value=4
Enter Value=3
Enter Value=2
Enter Value=1
MATRIX MULTIPLICATION

<<<MATRIX A
1  2  3
4  5  6
7  8  9
<<<MATRIX B
9  8  7
6  5  4
3  2  1
<<<MATRIX C
30 24 18
84 69 54
138 114 90

Posted By New18:24