Learning C/C++ with shrinivas
Friday, 26 April 2013
Tuesday, 23 April 2013
Writing Letter V with c language
/* If you don't understand below program send mail to vas.shrinivas002@gmail.com */
#include<stdio.h>
#include <conio.h>
int main(void)
{
clrscr();
void call();
void useme();
call();
useme();
}
void call()
{
int k,l;
for(k=1;k<=3;k++)
{
for(l=1;l<=k;l++)
{
if(l==k) {
gotoxy(k,l);
printf("*"); }
}
}//for
}
void useme()
{
int i,j,c;
for (i=1;i<=3;i++)
{
c=0;
for(j=6;j>=i;j--)
{
c=c+1;
}
gotoxy(c,i);
printf("*");
}
getchar();
}
-------------------------------------------------------------------- -----------------------
How to Write Letter B with c
/*prog for Letter B */
main()
{
int i=1;
for(i=1;i<=6;i++)
{
if(i==1 || i==4 || i==6)
{
printf("********");
printf("\n");
}
if(i!=1 && i<=5)
{
printf("* *");
printf("\n");
}
}
}
Monday, 22 April 2013
Sorting Technique
First understand this:
Let us assume we taken below array
var a=["9","8","3","2","8","11","7"]
First understand this:
step1:-->if (r[i]<=r[j])
t=t+1;
Above array 11 is biggest number,Based on above condition t will return
zenrate:t=1 for Highest no 11
t=2 for second biggest no 9
t=3 for third biggest no 8
t=4 for fourth biggest no 7
t=5 for fifth biggest no 3
t=6 for least no---------2
Now i am inserting highest number in last of array index that b[5]=r[i]
not understand see this b[5]=11,b[4]=9,b[3]=8,b[2]=7,b[1]=3,b[0]=2
Don't forget this is the key for writing sorting order
Order in this way:
Display in Ascending Order:a=["9","8","3","2","8","11","7"]
for(i=0;i<=4;i++)
{
document.write(b[i]);--->out put in this order 2,3,7,8,9,11
}
Also,If u want display in Descending Order this code will help you how
for(i=4;i>=0;i--)
{
document.write(b[i]);--->Out put is 11,9,8,7,3,2
}
----------------------------------------------------------------------------------
Next you can change below code in your environment(c,c++,c#,java)
<html>
<script type="text/javascript">
var r=new Array();
r[0]=1;
r[1]=237654;
r[2]=99999;
r[3]=99;
r[4]=10000;
var b=new Array();
var t=0;
document.write("Given format"+r);
document.write("<br />")
for (i=0;i<=4;i++)
{
for(j=0;j<=4;j++)
{
if (r[i]<=r[j])
{
t=t+1;
}
}
if (t==1)
{
b[4]=r[i];
document.write(" Highest no"+b[4]+"<br /> ");
}
else if(t==2)
{
b[3]=r[i];
document.write("second highest no"+b[3]+"<br /> ");
}
else if(t==3)
{
b[2]=r[i];
document.write("Third highest no"+b[2]+"<br /> ");
}
else if(t==4)
{
b[1]=r[i];
document.write("Fourth highest no"+b[1]+"<br /> ");
}
else if(t==5)
{
b[0]=r[i];
document.write("Least no"+b[0]+"<br /> ");
}
t=0;
}
document.write("Output in Ascending order:")
for(i=0;i<=4;i++)
{
document.write(b[i]+" ");
}
</script>
</html>
Let us assume we taken below array
var a=["9","8","3","2","8","11","7"]
First understand this:
step1:-->if (r[i]<=r[j])
t=t+1;
Above array 11 is biggest number,Based on above condition t will return
zenrate:t=1 for Highest no 11
t=2 for second biggest no 9
t=3 for third biggest no 8
t=4 for fourth biggest no 7
t=5 for fifth biggest no 3
t=6 for least no---------2
Now i am inserting highest number in last of array index that b[5]=r[i]
not understand see this b[5]=11,b[4]=9,b[3]=8,b[2]=7,b[1]=3,b[0]=2
Don't forget this is the key for writing sorting order
Order in this way:
Display in Ascending Order:a=["9","8","3","2","8","11","7"]
for(i=0;i<=4;i++)
{
document.write(b[i]);--->out put in this order 2,3,7,8,9,11
}
Also,If u want display in Descending Order this code will help you how
for(i=4;i>=0;i--)
{
document.write(b[i]);--->Out put is 11,9,8,7,3,2
}
----------------------------------------------------------------------------------
Next you can change below code in your environment(c,c++,c#,java)
<html>
<script type="text/javascript">
var r=new Array();
r[0]=1;
r[1]=237654;
r[2]=99999;
r[3]=99;
r[4]=10000;
var b=new Array();
var t=0;
document.write("Given format"+r);
document.write("<br />")
for (i=0;i<=4;i++)
{
for(j=0;j<=4;j++)
{
if (r[i]<=r[j])
{
t=t+1;
}
}
if (t==1)
{
b[4]=r[i];
document.write(" Highest no"+b[4]+"<br /> ");
}
else if(t==2)
{
b[3]=r[i];
document.write("second highest no"+b[3]+"<br /> ");
}
else if(t==3)
{
b[2]=r[i];
document.write("Third highest no"+b[2]+"<br /> ");
}
else if(t==4)
{
b[1]=r[i];
document.write("Fourth highest no"+b[1]+"<br /> ");
}
else if(t==5)
{
b[0]=r[i];
document.write("Least no"+b[0]+"<br /> ");
}
t=0;
}
document.write("Output in Ascending order:")
for(i=0;i<=4;i++)
{
document.write(b[i]+" ");
}
</script>
</html>
Prog for printing this kind of letters \/ and how to use gotoxy function like space
/*Below program for printing blank spaces and letters like 'V'
#include<stdio.h>
#include<conio.h>
main()
{
int i,j;
clrscr();
for(i=1;i<=6;i++)
{
for(j=1;j<=i;j++)
{
if(j==i)
{
printf("\n");
gotoxy(i,j);
printf("*");
}
}
}
#include<stdio.h>
#include<conio.h>
main()
{
int i,j;
clrscr();
for(i=1;i<=6;i++)
{
for(j=1;j<=i;j++)
{
if(j==i)
{
printf("\n");
gotoxy(i,j);
printf("*");
}
}
}
Subscribe to:
Posts (Atom)