Showing posts with label c. Show all posts
Showing posts with label c. Show all posts

Wednesday, February 18, 2015

C program to perform arithmetic operations using switch case


C program to perform arithmetic operations using switch case

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

void main()
{
int ch;
float a,b,res;
clrscr();
printf("Enter two numbers:");
scanf("%f%f",&a,&b);
printf("
Menu
1.Addition
2.Subtraction
3.Multiplication
4.Division");

printf("
Enter your choice:");

scanf("%d",&ch);

switch(ch)
{
case 1: res=a+b;
break;
case 2: res=a-b;
break;
case 3: res=a*b;
break;
case 4: res=a/b;
break;
default: printf("Wrong choice!!
Press any key...");

getch();
exit(0);
}

printf("
Result=%f",res);

getch();
}
Read more »

Tuesday, February 17, 2015

C program to print following square using character


#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,n;
clrscr(); //to clear the screen
printf("Enter size of the square:");
scanf("%d",&n);

for(i=0;i<n;++i)
{
printf("
");
for(j=0;j<n;++j)
{
if(i==0||i==n-1||j==0||j==n-1)
printf("*");
else
printf(" ");
}
}
getch(); //to stop the screen
}
Read more »

C Program to convert a lowercase alphabet to uppercase or vice versa

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
char ch;
cout<<"Enter any Alphabet:";
cin>>ch;

if(ch>=a&&ch<=z)
{
cout<<"
You have entered a lowercase alphabet";

ch=ch-32;
cout<<"

The uppercase alphabet is "<<ch;

}
else
{
cout<<"
You have entered an Uppercase alphabet";

ch=ch+32;
cout<<"

The lowercase alphabet is "<<ch;

}
getch();
}
Read more »

Monday, February 16, 2015

Turbo C for Windows XP How to Download and Install

Hello friends, after enjoying the festival of diwali I am back again to write something for you. Many visitors asked me that from where they can download turbo c++ for windows xp. So i thought that i should do something to help them. In this post i am giving you the link to download the compiler and step by step guide to install it.

Turbo C++ for Windows XP - How to Download and Install

- Click Here to Download Turbo C++ for Windows XP -


Also Read: Download Turbo C++ for Windows 8 for Free
Also Read: Download Borland C++ Compiler For Free

How to Install Turbo C++ for Windows Xp

1. First of all download the compiler from the link given above.
2. Now extract the zip file and than open TC3SETUP.
3. After that click on Unzip. You can also change the path where you want to install it.
4. By default it is installed in C:TC.
5. You have done!! Please share and like it.
Read more »

C Program to reverse all the strings stored in an array

C++ Program to reverse all the strings stored in an array

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>

void main()
{
clrscr();
char a[3][50];
int i,j,k,len;
cout<<"Enter 3 strings:
";


for(i=0;i<3;i++)
{
gets(a[i]);
}
cout<<"
The list of orignal strings:
" ;


for(i=0;i<3;i++)
{
cout<<a[i]<<"
";

}
cout<<"
The list of changed string:
";


for(i=0;i<3;i++)
{
len=strlen(a[i]);
for(j=0,k=len-1;k>=0;j++,k--)
{
cout<<a[i][k];
}
cout<<"
";

}
getch();
}
Read more »

Sunday, February 15, 2015

C program to swap two numbers using macros

C++ program to swap two numbers using macros

#include<iostream.h>
#include<conio.h>

#define SWAP(a,b) {int temp; temp=a; a=b; b=temp;}

void main()
{
clrscr();
int x,y;
cout<<"Enter two numbers:";
cin>>x>>y;

cout<<"x="<<x<<" y="<<y;
SWAP(x,y);
cout<<"
x="<<x<<" y="<<y;

getch();
}
Read more »

Saturday, February 14, 2015

C Program to explain Binary search in Array

C++ Program to explain Binary search in Array

#include<conio.h>
#include<iostream.h>

void main()
{
int search(int [],int,int);
clrscr();
int n,i,a[100],e=-3,res;
cout<<"How Many Elements:";
cin>>n;
cout<<"
Enter Elements of Array in Accending order
";


for(i=0;i<n;++i)
{
cin>>a[i];
}

cout<<"
Enter element to search:";

cin>>e;
res=search(a,n,e);
if(res!=0)
cout<<"
Element is Founded at "<<res+1<<"st position";

else
cout<<"
Element is not found....!!!";

getch();
}

int search(int a[],int n,int e)
{
int f,l,m;
f=0;
l=n-1;
while(f<=l)
{
m=(f+l)/2;
if(e==a[m])
return(m);
else
if(e>a[m])
f=m+1;
else
l=m-1;
}
return 0;
}
Read more »

C program to find factorial of any number using recursion

C program to find factorial of any number using recursion

#include<stdio.h>
#include<conio.h>

void main()
{
int fac,n;
int factorial(int);
clrscr();

printf("Enter any number:");
scanf("%d",&n);

fac=factorial(n);
printf("Factorial=%d",fac);
getch();
}

int factorial(int x)
{
int f;
if(x==1||x==0)
return 1;
else
f=x*factorial(x-1);

return f;
}
Read more »

Friday, February 13, 2015

C program to print the following pattern


C++ program to print the following pattern:

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr(); //to clear the screen
int i,j,k,n;
cout<<"How many lines?";
cin>>n;
n*=2;

for(i=0;i<n;i+=2)
{
cout<<"
";

for(j=n;j>i;j-=2)
cout<<" ";
for(k=0;k<=i;++k)
cout<<"*";
}
getch(); //to stop the screen
}
Read more »

Thursday, February 12, 2015

C program to find greatest number among three numbers


C program to find greatest number among three numbers

#include<stdio.h>
#include<conio.h>

void main()
{
int x,y,z,max;
clrscr();
printf("Enter The Three Numbers:");
scanf("%d%d%d",&x,&y,&z);

max=x;
if(y>max&&y>z)
max=y;
else
if(z>max)
max=z;
printf("
The Greatest Number among %d %d %d is %d",x,y,z,max);

getch();
}
Read more »

C program to add two numbers using structure

C program to add two numbers using structure

#include<stdio.h>
#include<conio.h>

struct sum
{
int a;
int b;
};

void main()
{
int sum1;
struct sum s;
clrscr();

printf("Enter two numbers:");
scanf("%d%d",&s.a,&s.b);

sum1=s.a+s.b;
printf("
Sum=%d",sum1);

getch();
}
Read more »

C program to swap two numbers using pointers


C++ program to swap two numbers using pointers

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int *a,*b,*temp;
cout<<"Enter value of a and b:";
cin>>*a>>*b;

temp=a;
a=b;
b=temp;

cout<<"
After swaping
a="<<*a<<"
b="<<*b;

getch();
}
Read more »

C program to find sum of series 1 1 2 2 1 3 3 1 n n


C++ program to find sum of series 1+1/2^2+1/3^3+.....+1/n^n

#include<iostream.h>
#include<conio.h>
#include<math.h>

void main()
{
clrscr();
double sum=0,a;
int n,i;
cout<<"1+1/2^2+1/3^3+.....+1/n^n";
cout<<"
Enter value of n:";

cin>>n;

for(i=1;i<=n;++i)
{
a=1/pow(i,i);
sum+=a;
}

cout<<"Sum="<<sum;
getch();
}
Read more »

CppDroid – C C IDE for Android Platform

CppDroid is a simple C/C++ IDE for Android platform which is focused on learning programming languages and libraries. I found this IDE while searching on the internet for C4droid alternatives. It can be an awesome alternative of C4droid compiler. By using this app you can easily write and run C/C++ programs on android device. Apart from writing and running programs you can get many C/C++ examples and tutorials inside it. So before downloading let’s take a look on some features of CppDroid.

CppDroid – C/C++ IDE for Android Platform

Also Read: C4droid Apk Free Download - C/C++ Compiler for Android Platform

Features of CppDroid

  • Code complete
  • Real-time diagnostics (warnings and errors) and fixes
  • File and tutorial navigator (variables, methods, etc)
  • Static analysisSmart syntax highlighting
  • Portrait/landscape user interface
  • Auto indentation and auto pairing (configurable)
  • Configurable code syntax highlighting (themes)
  • Compile C/C++ code (no root required)
  • Works offline (built-in compiler, no need of internet connection)
  • Great C/C++ code examples included
  • Detailed C++ tutorial and learn guide included
  • Add-ons manager and auto updates
  • Dropbox support


CppDroid – C/C++ IDE for Android Platform

CppDroid – C/C++ IDE for Android Platform

When you run CppDroid for first time, it will extract SDK which is about 150MB in size and also download and extract many examples and tutorials. Approximately 190MB of internal storage space is required to install this app. This cant be moved to external sd card because of android security. Just download CppDroid for free from below link. The link will redirect you to google play store.

Download CppDroid – C/C++ IDE for Android Platform


Just try CppDroid and share your experience with us.
Read more »

Wednesday, February 11, 2015

C Program to perform all arithmetic calculation using switch case

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
float a,b,res;
int ch,q;
cout<<"Arithmetic Operatios";
cout<<"

1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Mode";

cout<<"
 Enter your choice:";

cin>>ch;

switch(ch)
{
case 1:
{
cout<<"

Enter two variables:";

cin>>a>>b;
res=a+b;
cout<<"
 Result="<<res;

}
break;

case 2:
{
cout<<"

Enter two variables:";

cin>>a>>b;
res=a-b;
cout<<"
 Result="<<res;

}
break;

case 3:
{
cout<<"

Enter two variables:";

cin>>a>>b;
res=a*b;
cout<<"
 Result="<<res;

}
break;

case 4:
{
cout<<"

Enter two variables:";

cin>>a>>b;
if(a>=b)
{
res=a/b;
cout<<"
 Result="<<res;

}
else
cout<<"

1st varable should be greater than 2nd.!!!";

}
break;

case 5:
{
cout<<"

Enter two variables:";

cin>>a>>b;
if(a>=b)
{
q=a/b;
res=a-(b*q);
cout<<"
 Result="<<res;

}
else
cout<<"

1st variable should be greater than 2nd..!!!";

}
break;
}

getch();
}
Read more »

C Program to find divisers of a number


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long int n,i;
cout<<"Enter the number: ";
cin>>n;
cout<<endl<<"Divisers of "<<n<<" are ";
for(i=1;i<=n;++i)
{
if(n%i==0)
cout<<" "<<i;
}
getch();
}
Read more »

Tuesday, February 10, 2015

Valentine’s Day Special C Program to Print Heart Shape with Happy Valentine’s Day Message inside it

Today’s day is very special for all lovers. So I thought that I should share some programming stuff that show Valentine’s Day felling. A C++ program is given below which prints heart shape with a Happy Valentine’s Day message inside it. If you want, you can change the message by changing the value of string message. I hope that you will like this.

Also Read: Simple program to create a moving car in graphics
Also Read: Simple program to create a circular loading bar using graphics


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    double x, y, size=10;
    char ch=3;
    string message(" Happy Valentines Day ");
    int print_line = 4;

    if (message.length() % 2 != 0) message += " ";

    for (x=0;x<size;x++)
    {
        for (y=0;y<=4*size;y++)
        {
            double dist1 = sqrt( pow(x-size,2) + pow(y-size,2) );
            double dist2 = sqrt( pow(x-size,2) + pow(y-3*size,2) );

            if (dist1 < size + 0.5 || dist2 < size + 0.5 ) {
                cout << ch;
            }
            else cout << " ";
        }
        cout<<"
";
    }

    for (x=1;x<2*size;x++)
    {
        for(y=0;y<x;y++) cout << " ";

        for (y=0; y<4*size + 1 - 2*x; y++)
        {
            if (x >= print_line - 1 && x <= print_line + 1) {
                int idx = y - (4*size - 2*x - message.length()) / 2;
                if (idx < message.length() && idx >= 0) {
                    if (x == print_line) cout<<message[idx];
                    else cout << " ";
                }
                else cout << ch;
            }
            else cout << ch;
        }
        cout<<endl;
    }
    return 0;
}

Valentine’s Day Special: C++ Program to Print Heart Shape with Happy Valentine’s Day Message inside it
Read more »

C program to find largest number of a list of numbers entered through keyboard


C++ program to find largest number of a list of numbers entered through keyboard


#include<iostream.h>
#include<conio.h>


void main()
{
clrscr(); //to clear the screen
int i,n,x,large=0;

cout<<"How many numbers?";
cin>>n;
for(i=0;i<n;++i)
{
cout<<"
Enter number "<<i+1<<":";

cin>>x;
if(x>large)
large=x;
}
cout<<"

The largest number is "<<large;

getch();
}
Read more »

Monday, January 26, 2015

Complete C Video Tutorials in Urdu Hindi

Complete C++ Video Tutorials in Urdu & Hindi

C++ is a high-level programming language that was developed in the mid-1970s. It was originally used for writing Unix programs, but is now used to write applications for nearly every available platform. Compared to most previous languages, C is easier to read, more flexible (can be used for a wide variety of purposes), and more efficient at using memory.

C++, pronounced "C plus plus," is a programming language that was built off the C language. The syntax of C++ is nearly identical to C, but it has object-oriented features, which allow the programmer to create objects within the code. This makes programming easier, more efficient, and some would even say, more fun. Because of the power and flexibility of the language, most software programs today are written in C++.


Here is the Two Different Complete Courses of C++ which contains more than 30 videos and more videos will be added in coming days. This is a playlist of videos straight from my YouTube channel, so you can watch all the videos by playing only the first one. This course is with full sorting, so you can watch the videos in order.




Complete Tutorial (11 Videos)









Complete Tutorial (36 Videos)



Note: All videos are hosted on YouTube.com, so if you are in Pakistan then first open YouTube and then watch these videos.

Read more »