Programming in C/C++

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
Hey guys... This is a new thread for programming in C/ C++ Pls post ur questions and examples here........



41R9XVJFJQL.jpg


:yes::yes::yes::yes::yes::yes::yes::yes::yes::yes::yes:
 
Last edited:

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
1st program........ in C

#include<stdio.h>
#include<conio.h>
void main()
{

printf("Hello Programming....");

}

Using Borland TC 3.0v
 
Last edited:

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
//C program to print the numbers 1-9 vertically
#include<stdio.h>
#include<conio.h>
void main()
{
int x;
clrscr();
for(x = 1; x <=9; x = x+1 )
{

printf("%d", x);
printf("\n");
}
getch();



}
 

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
C program to print the sequence of numbers given below......


1
12
123
1234
12345



#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
clrscr();
for(x =1; x <=9; x = x+1)
{
for (y = 1; y<=x; y = y +1)
{
printf("%d", y);
}
printf("\n");
}
getch();

}
 

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
C program to check the character that you have entered.....


#include<stdio.h>
#include<conio.h>
void main()
{
char y;
clrscr();
printf("Enter any character...");
scanf("%c", &y);
if (y >='A' && y <= 'Z')
printf("You typed a Capi....");
else if (y >='a' && y <='z')
printf("You typed a Simple.....");
else if (y >='0' && y <='9')
printf("you typed a digit..");
else
printf("you typed a special char.....");
getch();

}
 

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
A simple C program to get ur NIC number and show the details....


//Nic & details display
#include<stdio.h>
#include<conio.h>
void main()
{
char myic[11];
char my[5], md[4];
int i,j,y,m,d,msex;
int mon[12]={31,29,31,30,31,30,31,30,31,30,31,30};
clrscr();
printf("enter your NIC......? ");
gets(myic);
for (i=0; i <=1; i++)
my = myic;
y = atoi(my);
j=0;
for(i =2; i <=4; i++)
{
md[j]=myic;
j=j+1;

}
m = atoi(md);

if (m >500)
{
msex= 0;
m= m-500;

}
else msex = 1;
i=0;
while (m> mon)
{
m= m-mon;
i=i+1;

}
printf("Your Nic num.......= %s\n",myic);
if (msex ==0)
printf("Your sex Female");
else
printf("your sex is Male..\n");
printf("Your B.Yr.......= %d\n",y);
printf("Your B.month.....= %d\n",i+1);
printf("Your B.Date.......= %d\n",m);
getch();
}
 

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
//prog make given charcter to upper case
#include<stdio.h>
#include<conio.h>
void myupper(char c);
void main()
{
clrscr();
myupper('d');
myupper('e');
myupper('a');
getch();

}
void myupper(char c)
{
char x;
x=c;
if(c >= 'a' && c <= 'z')
x = x-32; //A=97 a= 65 (dofference bet.Capital & simple)
printf("\n %c \n",x);

}
 

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
//Program to Enter Marks For TWO subj.using ARRAY and SORT them.
#include<stdio.h>
#include<conio.h>
void arsort(int x[],int y);
void main()
{
int science[5],social[5];
int i;
for(i=0;i<=4;i++)
{
printf("\n enter science marks?");
scanf("%d",&science);
printf("\n enter social marks?");
scanf("%d",&social);
}
printf("\n marks before sort");
for(i=0;i<=4;i++)
printf("science %d social %d\n",science,social);
printf("\n marks after sorted\n");
arsort(science,5);
arsort(social,5);
getch();

}
void arsort(int x[],int y)
{
int j,k,t;
for(j=0;j<=y-1;j++)
{
for(k=0; k<=y-1; k++)
{
if (x[k] > x[k+1])
{
t=x[k];
x[k] = x[k+1];
x[k+1] = t;
}
}
}
for(j=0;j<=y-1;j++)
printf("\t%d\t",x[j]);
printf("\n");


}
 

hasiwebmail

Member
Feb 27, 2007
501
52
0
Sri Lanka
machan mewa kohomada use karanne kiyala kiyanawada banz
mama asai me gena igena ganna podi podi softweres create karanna balanna
danna kenek innawa nam kiyala denna

Mulin ma simple algorithms try karala balanna, Borland C/C++ free compiler ekak hugak study purpose ekata use karana. Godak university wala karannet meka,
Ms-dos installation ekak tiyenne. Down karala try karala balanna..
meka v3.0

http://www.brothersoft.com/turbo-c-182798.html

V4.5 torrent eka menna

http://www.torrentdownloads.net/download/937030/Borland+Turbo+C%2B%2B+4+5+%5BVARKEY%5D
 
Last edited:

Enigma_1

Junior member
  • Feb 5, 2008
    70
    3
    8
    Colombo
    menna simple code ekak. Win32 Api use wena. meka simple messenger program ekak. meka run karama notepad eka open wela automatically message ekak type wenwa

    Code:
    #include <windows.h>
    const char* message = "hello people this is a one stupid message";
    
    HWND hnotepad=0,hedit=0;
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
    {
        
        ShellExecute(NULL,"open","notepad.exe",NULL,NULL,SW_SHOW);
        Sleep(100); // As far as I know this is because the ShellExecute() is slow &
                     // we have to wait some time for the notepad to be fully created by the OS
        hnotepad = FindWindow("Notepad",NULL); // getting the handle of the notepad
        if(hnotepad)
        {
            hedit = FindWindowEx(hnotepad,0,"edit",NULL); // getting handle of the textbox 
        }
    
        if(hedit)
        {
            while(*message !=NULL)
            {
                SendMessage(hedit,WM_CHAR,*message,(int)*message); // sending the WM_CHAR message 
                Sleep(200); // Increase this value and the typing speed will be decreases
                message++;
            }
        }
    
        return 0;
    }
    :rofl::rofl::rofl::rofl::rofl::rofl:
     

    Enigma_1

    Junior member
  • Feb 5, 2008
    70
    3
    8
    Colombo
    hi guyss. that was my first post for elakiri.com. C++ kiyanne tikak complected language ekak. mama damma program eke C++ basics use wela thiyenne pointers witharai. other than that all the codes are based on WIN32 APIs . mamath hamadema danne na. eth danna tika kiyala dennum. kisma aulak na :D. Eth eka kohomada karanne kiyana eka oyagollo kiyanna. mokada mama me forum ekata aluth.
     
    Last edited: