Search This Blog

Read Your Language

Showing posts with label C Language. Show all posts
Showing posts with label C Language. Show all posts

Basic Calculator in C

Basic Calculator made by C Programming 

#include<stdio.h>
#include<conio.h>
int main()
{
    int a, b,c, choice;
    float d;

printf("-----------------Basic Calculator ------------------------\n");

printf(" -----------Please Type The your choice (1-4) ------------\n");
printf(" 1.Addtion\n ");

printf("2.Subtration  \n ");

printf("3.Multipication\n ");

printf("4.Division \n ");
    scanf("%d",&choice);

switch(choice)
{
case 1:     printf(" please Enter the Two numbers \n");
            scanf("%d%d",&a,&b);
            c=a+b;
            printf("Your addition is the : %d",c);
            break;
case 2: printf(" please Enter the Two numbers\n ");
            scanf("%d%d",&a,&b);
            c=a-b;
            printf("Your Subtraction is the : %d",c);
            break;
    case 3:     printf(" please Enter the Two numbers \n");
            scanf("%d%d",&a,&b);
            c=a*b;
            printf("Your Multipication is the : %d",c);
           break;
case 4: printf(" please Enter the Two numbers \n");
            scanf("%d%d",&a,&b);
            d=a/(float)b;
            printf("Your Division is the : %0.4f",d);
            break;
default : printf("Wrong type your Choice ");          
               break;
   }
}



OUTPUT: 

-----------------Basic Calculator ------------------------
-----------Please Type The your choice (1-4) ------------
1
please Enter the Two numbers
4 6
Your addition is the :10

ADDITION,SUBTRACTION ,MULTIPICATION & DIVISION IN C


//Write a user defined  two no is add , subtraction ,division and multipication?

#include<stdio.h>

#include<conio.h>

main()

{

 float a,b, c;

 printf("ENTER THE TWO NUMBERS :\n");

 scanf("%f%f",&a,&b);

 c=a+b;

 printf("\nTwo numbers sum is : %f",c);

        printf("\n\nENTER THE TWO NUMBERS :\n");

  scanf("%f%f",&a,&b);

 c=a-b;

    printf("\nTwo numbers Subtraction  is : \n%f",c);

    printf("\n\nENTER THE TWO NUMBERS :\n");

     scanf("%f%f",&a,&b);
    c=a/b;

    printf("\nTwo numbers division is :\n %f",c);

    printf("\n\nENTER THE TWO NUMBERS :\n");

    scanf("%f%f",&a,&b);

    c=a*b;

    printf("\n\nTwo numbers multipication is : \n%f",c);

    getch();

   return 0;

}



All character display of its ASCII value.


Write a program all character display of its ASCII value. 

/*Write a program which accepts a character and display its ASCII value. */

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

char c;
int i;
for(i=1;i<255;i++)
{
c=i;
        printf("%d.ASCII CODE IS %d=%c\n",i,i,c );
}


Three variable swaping in C program


Write a program is three variable swaping  in C program.
#include<stdio.h>
main()
{
int a,b,c,swap;
a=1;
b=2;
c=3;
printf(" Swaping before the value of variable  is :  %d, %d  & %d\n",a,b,c);
swap=a;
a=b;
b=c;
c=swap;
printf(" \nSwaping after the the value of variable is : %d, %d  & %d\n ",a,b,c);

}



The number is divisible by 100 or not

Write a program is  any number takes from user. Display whether the number is divisible by 100 or not. 



#include<stdio.h>
main()
{
int i=100,n;
    printf("Enter the any postitive integers:\n");
scanf("%d",&n);
(n%100==0) ? printf(" yes this number is disivible of 100 : %d",n):printf(" No this number is not disivible of 100 :%d",n);

}


Find greater and smaller number from given two numbers


      Find greater and smaller number from given two numbers


/*write a program to find greater and smaller   number from given two numbers. */

#include<stdio.h>
main()
{   int y,z;
printf("Enter the two numbers\n");
scanf("%d%d",&y,&z);
if(y>z)
{
printf(" %d greater number than %d  &   smaller number is %d \n",y,z,z);
}
else
{
printf("%d greater number than %d  &   smaller number is %d \n",z,y,y);
}
}


HOW TO WRITES IN C PROGRAM ?


All IT student is writes a C program before learn about how to writes in C program. It major rule to understanding how to be perform C in program .


How to writes in C program in  Programming ?

STEP 1: Writes a header file 
STEP 2: Writes a Main() { main() it called is main function} 
STEP 3: Writes a main() after  curly brace {
STEP 4: Writes a statement inside the Main()
STEP 5:  If requires  takes return statement 
STEP 6:  after statement  Closed the curly brace }



HEADER FILE 


Header file more type in C program . It major used in header file  this C program is #include<stdio.h>.


#include<stdio.h>

#              means preprocessor directive . 
include   means user and system are linking together 
<>           it shows inside the less than between greater than is                          which type of header file 
stdio       std means standard ,i means input & o means output
.h            extension file  of  C 


Main()

main() is treat all statement inside  the curly braces {} in C program.

{
it show the start the of the program C .


STATEMENT

Writes a code inside the curly braces{} as want you  required of C program.


Return 

if require the C program.


}

Closed the statement of C Program.



FOR EXAMPLE OF BASIC PROGRAM IN C  :

#include<stdio.h>                          // this is a header file 
main()                                            // this is predefined function 
{                                                    printf("hello friend your first program in C "); // statement
return 0;                                         //pass the return value 
}

Conditional opreator in C



Write a program is the conditional opreator in the C program?

Conditional operator also known is ternary operator.
Conditional operator syntex is :
(condition) ? true statement : false statement 
      for example :
           int a =5, int=7
           (condition) ? true statement : false statement 
                (a>b)      ?     print first       : if not then print second

/* hi friend today learn about the conditional operator used in C program */

#include<stdio.h>
main()
{   int a,b;
             printf("your  two positive no is : %d & %d \n",a,b,scanf("%d%d",&a,&b));
//scanf("%d%d",&a,&b);
(a>b) ?printf(" your %d  is the greater than %d  ",a,b):printf("your %d  no is the greater than %d",b,a);

}

OUTPUT:

6  7
your  two positive no is : 6 & 7
your 7 no is the greater than 6

calculate the net_salary of an officers


Write a program is the calculate the net_salary of an officers. if  officers not come in the office then  deducted  the salary on  his gross-salary .


#include<stdio.h>


main()

{     int net_salary,gross_salary=13000,n,day=30;

      printf(" Enter the day not of come in the  officers:\n");

      scanf("%d",&n);

if(day>n)

{
                
   net_salary=gross_salary/30*n;

    printf(" your net salary  deducted is : %d",net_salary);

}

else

{

   printf(" Not deducted from salary . your salary net salary has paid %d",gross_salary);

}

}


OUTPUT :
Enter the day not of come in the  officers:
1
your net salary  deducted is : 433

C IN QUESTIONS

                           QUESTIONS 

Q1. What number of the tokens in this  C statement ?
        printf("hello friend");

: please answer comment this site. your answer has right yes or no after reply some times if any problem kindly suggest me.

Q2. What is Output of this program?
              #include<stdio.h>
              main()
            {  
            printf(""hello"");
     }

:please answer comment this site. your answer has right yes or no after reply some times if any problem kindly suggest me.

 Q3. What is Output of this program ?
         #include<stdio.h>
          main()
          {  
          printf("hello\r ");
  }

please answer comment this site. your answer has right yes or no after reply some times if any problem kindly suggest me.
Q4. What is return value in C program ?

please answer comment this site. your answer has right yes or no after reply some times if any problem kindly suggest me.

Q5.  What is  diffreance between Structure and Union ?  

please answer comment this site. your answer has right yes or no after reply some times if any problem kindly suggest me.

Sample program of the string in C

                   Sample program  of the string in C 



The basic program is the string of show in the below of the following . Meanwhile , we knows that string is the indentifier then defind the character .string show on the  format specifier is the %s.Further , String the most important of the chapter in  C language .

#include<stdio.h>
#include<string.h>
main()
{
char string[45];
printf("Enter the string of character:\n ");
scanf("%s",string);
printf("Enter your string is the : %s",string);
return 0;
}


OUTPUT:
Enter the string of character: 
Hi
Enter your string is the : Hi

Write a C program to find the factorial of a given number.

Write a C program to find the factorial of a given number.

#include<stdio.h>
main()
{
int fact=1, i,n;
printf("enter the number:\n ");
scanf("%d",&n);
for(i=1;i<=n;i++)
fact=fact*i;
printf("%d factorial  is the : %d",n,fact);
   
}

OUTPUT:
enter the number:
4
4 factorial  is the : 24


Write a program to find the largest number in a given array of 10 elements.

Write a program to find the largest number in a given array of 10 elements.

/* Write a program to find the largest number in a given array of 10 elements*/
#include<stdio.h>
main()
{
int arr[10], size,largest_no,i;
printf("enter the 10 element's size of the Array ");
scanf("%d",&size);
for(i=0;i<size;i++)
scanf("%d",&arr[i]);

largest_no=arr[0];
for(i=0;i<size;i++)
{
if( largest_no<arr[i])
largest_no=arr[i];
        }
        printf("the largest no of the ten is : %d",arr[i]);
        return 0;

}

Tokens, Whitespace & Constants

                                  

Tokens in C 
A tokens consist of the a keyword, an identifier, a constant, a string literal, or a symbol.

                                  


Whitespace  in C 
Whitespace is the used the  describe blanks, tabs, newline characters and comments.
                                             
                         


Constants 
constants define the fixed value then not alter then execute at a time of the program.


                                                      

Types of Constructor

Types of Constructor

There are fives types of  the using of  Constructor in C++
  1. Default Constructor 
  2. Parametrized Constructor
  3. Copy Constructor 
  4.  Overloading Constructor 
  5. Constructing two Dimensional Construtor 

  1. Default Constructor :Below show of  the program in the default constructor of the C++. Its has no parameter argument. 
#include<iostream>
using namespace std;
class default1
{

public:
int a,b;
default1()// that called be default constructor 
{
                  a=5;
                 b=8;
}
};
int main()
{   default1 x;
cout<<"a:"<<x.a<<endl<<"b:"<<x.b;
}
OUTPUT:
a:5
b:8

C LANGUAGE


C LANGUAGE ABOUT IN HINDI 

आज हम C  लैंग्वेज के बारे में सीखने जा रहे है | आखिर हम C लैंग्वेज को क्यू  सीखते है | इसे सिख कर  क्या बना जा  सकता है |  चलिए  दोस्तों आज हम बताते है  C लैंग्वेज  सिखने से आपको क्या क्या फायदे  होने वाले है |

C  लैंग्वेज को सिख कर आप बहुत अच्छे  प्रोग्रामर   बन  सकते है  और  यंहा तक की आप खुद की  एक सॉफ्टवेयर बना सकते है |  प्रोग्रामिंग की दुनिये में C  लैंग्वेज का बहुत अच्छा महत्तव है |



C एक Popular Programming Language है और यह सभी  Programming Language से काफी सरल और आसान है ।

C is a Popular Programming Language and it is much simpler and easier than all Programming Language.

C  एक  Simple  Procedure Oriented Language है इसको हम System Programming Language , Structured Programming Language या Mid-level Programming Language भी कह सकते है ।

C is a simple procedure oriented language, it can also be called System Programming Language, Structured Programming Language or Mid-Level Programming Language.

इसकी खोज सबसे पहले  Dennis M. Ritchie 1972  में Bell Telephone Laboratories में UNIX Operating System का विकास करने के लिए  | C  Language का प्रयोग अधिकतर लोग करते है |

It was first discovered by Dennis M. Ritchie in 1972 to develop the UNIX Operating System at Bell Telephone Laboratories. Most people use C Language.


    Dennis M. Ritchie  

C का आविष्कार UNIX नामक एक ऑपरेटिंग सिस्टम को लिखने के लिए किया गया था। UNIX OS पूरी तरह से C में लिखा गया था C, B भाषा का Successor  है जिसे 1970 के दशक के प्रारंभ में शुरू किया गया था


C was invented to write an operating system called UNIX. UNIX OS was written entirely in C, C is the successor of B language which was started in the early 1970s.

आज का सबसे लोकप्रिय Linux OS और RDBMS My SQL  C  में लिखा गया है। इसके अलवा C का प्रयोग खासतौर  पर  Operating system, and Embedded System  development करने के लिए किया जाता है ।

Today's most popular Linux OS and RDBMS is written in My SQL C. Apart from this, C is especially used for operating system, and Embedded System development.

C को Mother Language  के रूप में जाना जाता है क्योंकि अधिकांश compilers  और JVM  C भाषा में लिखे गए हैं  यह  Structured language  होता है  | इस कारण हम इसमे गलतियों को आसानी से पकड़  सकते है |

C is known as Mother Language because most compilers and JVM are written in C language. It is structured language. For this reason, we can easily catch mistakes in it.

C  Language को Accuracy  की झमता बहुत अधिक होती है | C PROGRAM जिसका EXTENSION  .C या  .H  होता है।
 
Accuracy of C Language is very high. C PROGRAM with EXTENSION .C or .H. 

C  Language  को सिखने  के लिए आप Market  के कोई  भी एक टेक्स्ट एडिटर कम्पाइलर का इस्तेमाल कर सकते है जिसमे से निम्नलिखित निचे दिए गए है :
§    DEV C++ 
§    CODE BLOCKS
§    TURBO C
§    Visual C++ Express etc.
इसके अलावा  मार्किट में बहूत तरह के कम्पाइलर मौजूद है |

To learn C language, you can use any text editor compiler in the market, out of which the following are given below:

§    DEV C++ 
§    CODE BLOCKS
§    TURBO C
§    Visual C++ Express etc.
Apart from this, many types of compilers are available in the market.

Contact Form

Name

Email *

Message *

Followers