Sunday, March 3, 2019

keywords in C || how many keywords in C|| with simple programs



kyewords-in-c
kyewords-in-c

              keywords in C
 || how many keywords in C||


 there are 32 keyword in C

 auto         double        int                struct
 break       else             long             switch
case          enum          registered     typedef
char          extra           data              Union
const         float           short             unsigned
continue    for              signed          void
default      goto            sizeof           volatile
do              if                static             file

DATA TYPES IN C

           NAME        SHORT       SIGN      TAKE BITE 
  
integer          int              %D              2
character      char           %c                1
float              float         %f                 4
string            str            %s                 2
doube           double     %ld                8
long              long        %lf                10
long integer long int    %ld                4


SIMPLE PROGRAMS

Q1:-make a program who print "hello world"

#include<stdio.h>
#include<conio.h>
void main()
{
clrser();
printf("hellow world");
getch();
}
output:-   hellow world


Q1 make a simple program who print      1
                                                                 23
                                                                456 


#include<stdio.h>
#include<conio.h>
void main()
{
clrser();
printf("1\n 23\n456\n");
getch();
}


DATA TYPE VICE PROGRAMS

INTEGER
SHORT NAME - INT    SING-  %d
TAKE BYTE -2
RANGE= -32768  To 32767

Q1 MAKE A PROGRAME WHO ADD A=5 ,B=5 AND PRINT OUTPUT

#include<stdio.h>
#include<conio.h>
void main()
{
clrser();
int a=5, b=4;
Sum=a+b;
printf("%d",Sum);
getch();
}

Q2 MAKE A PROGRAME WHO ADD TWO NUMBERS AND PRINT OUTPUT

#include<stdio.h>
#include<conio.h>
void main()
{
clrser();
int a,b sum;
printf("enter a &b");
scanf("%d,%d",&a,&b);
sum=a+b;
printf("please sum the two values %d", sum);
getch();
}

Q3 make a program  calculate the area of rectangle:



#include<stdio.h>
#include<conio.h>
void main()
{
clrser();
int a,b area;
printf("enter a&b");
scanf("%d,%d",&a,&b);
area=a*b;
printf(" %d", area);
getch();
}

                                                                  FLOAT



Q1 MAKE  A PROGRAM  FOR TEMPRATURE CHANGEMENT
#include<stdio.h>
#include<conio.h>
void main()
{
clrser();
float c,f;
printf("enter f");
scanf("%f",&f);
c=(f-32)*5/9;
printf("%f", c);
getch();
}





Wednesday, January 23, 2019

how to run c program in android


        how to run c program in android


STEP 1

For this, you need to download two files whose link is given below.

LINK 1 (ZIP FILE)-CLICK HERE
LINK 2 (APK FILE)- CLICK HERE



 STEP 2






after downloading the files you have to create a TC named folder
 in internal memory and extract the file of the first link in TC folder.

 STEP 3-

the second link has an APK file install on it. and start APK when you start the app you will see a button name start emulator which has to be clicked


STEP 5

after doing so the end Box with start and a black colour interface will appear after this you can see three dots on the

bottom side click on it and then you will see a dialogue box and click keyboard button and type step by step

  1.   cd tc press enter
  2.   cd bin  press enter
  3.   tc.exe press enter





 STEP 5

" now c  is open"


 you cannot use its cursur by clicking on it like Android.  you have to use it by sliding finger and click like a mouse

DOWNLOAD ALL PROCESS IN VIDEO CLICK HERE




Tuesday, January 15, 2019

control statements in 'C' and it's input/output


input / output in C



 most languages have facility for input and output, built into the language. the C language does not have built in statement of I/O full stop it has function to achieve the I/O. the standard I/O function (  scanf(),printf()) are normally performed by using the "studio.h" header file. it has conio.h header file to perform console I/O function(gets), puts(),getchar,etc.

 standard I/O functions

* scanf()

 this function allow to enter data from keyboard that will be   formatted  in a certain way full stop the journal  form of  scanf( ) statement is

scanf(" formatted string", list of address of variables):

FOR EXAMPLE

scanf("%d%F,"&a,&b);

 here and donate the address of operator this is necessary because the values received from keyboard must be dropped in two variables corresponding to this addresses.
%d and %f are format specifiers which work as conversion characters. format specifier used to in C are as follows:

 format specifier                    data types

  •  %d,%i                                               signed integer
  • %u                                                     unsigned integer
  • %ld,%li                                             long integer
  • %lu                                                    unsigned long integer
  • %f                                                      float
  • %lf,%le,%lg                                     double
  • %Lf,%Le,%Lg                                 long double
  • %c                                                     character
  • %s                                                     string, group of characters


* printf()

 this function writes formatted data to screen. this function allowed to supply the input in a fixed format and to obtain the output in the  specified form. the printf()  function interprets the contact of the format string.
 syntax
 printf("formatted string" , variables);

 example 1

printf (" average =%d percentage=%f",avg.per);

here the %d and %f are conversion characters.
 They printf() to print the value of avg as an integer and per as a float.


 example 2.

 printf (" hello student \n how\t are\t you");

 here \n,  \t are escape sequence. escape sequence used to in C are

escape sequence                   function (output)


  • \a                                           beep (alert)
  • \b                                          black space
  • \n                                            new line
  • \t                                           horizontal tab
  • \\                                           backslash
  • \,                                          single quote
  • \"                                          double  quote
  • \V.                                        vertical tab
  • \?                                        question mark
  • \0000.                                 code specified in octal
  • \xhh                                    code is specified in hexadecimal


 console I/O functions


  •  getch()                                               reads a character from keyboard
  •  getche()                                             read a character from keyboard and echoes it
  • getchar()                                             reads a character from keyboard (macro version)
  •  gets()                                                 read a line from keyboard
  • putchar()                                             writes are  to a screen (macro version)
  • puts()                                                  writes a line
  •  scanf()                                               reads formatted data from keyboard
  • printf()                                                writes formatted data to screen

 control statements in 'C'

 to control the flow of the execution of program, the C language provides the following statements

 conditional statements:

 these statements enable us to  change the flow of the program. in other words, these statements are used to transfer the control from one point to another point (depend on condition(s)). in C language following conditional statements are used:

if statement/if-else statement 

This statement allows decisions to be made by evaluating a given condition as true or false. The keyword it tells the compiler that it is a decision control instruction. the condition if is always enclosed within a pair of Parenthesis. The relational operators allow us to compare two values to see whether they are  equal to each other, greater or less than the other. The general form of if statement is
 if ( condition)
{
statements
}
 ·in the above example  statements are executed when condition is true
 if ( condition (s) )
 {
statement 1
 }
 else
{
statement 2
}

  In t this statement 1 will be executed when the condition is true otherwise statement 2 will be executed.

Switch Case Statement :

 This control statement, which allows us to make a decision from the number of choices is called a switch. With the  help of switch and case statements we may choose any number of decisions, or more correctly a switch-case default, since the combination of these three key words go together to make up the control statement.
 Syntax=>
 switch ( expression)
{
 case 1:
statements (Group 1)
 case 2 :
 statements (Group 2)
 case 3 :
statements (Group 3)
 default:
 statements ( Group 4)
}
The switch statement checks, whether an expression matches with number of integer or character constant.

 Example : for  "if-else"

 # include < stdio.h >
 void main ( )
 {
 int age;
 printf ("Enter your age");
scanf("% d", & age);
if (age>= 18)
 {
printf("You can vote");
 else
printf ("You can't vote");
 }
getch();
}

Example : for "switch -case" 

To calculate simple interest and compound interest.
#include< stdio.h >
#include< conio.h >
 void main ()
 {
 int ch;
float p, r, t, si, ci;
 clrscr ( );
printf ("Enter principle");
 scanf("¾f", & p);
printf ("Enter rate \n");
 scanf ("%f", & r);
 printf ("Enter time \n");
 scanf ("% f", & t);
printf("\n 1. Simple Interest");
 printf("\n 2. Compound Interest");
printf("\n Enter your choice \n'-');
scanf ("% d ", & ch);
switch (ch)
{
 case 1:
si = (p * r * t) / 100 ;
 printf ("% f\ n", si);
break;
case 2:
ci = p ( ( 1 + r/100) ^t -p);
printf (" % f\ n", ci );
break;
default:
 printf ("wrong choice");
}
 getch ( );
}

* Looping Statements :

 A computer program is a set of statements,  which is normally executed sequentially. But in most of the cases it is necessary to repeat certain steps to meet a specific condition. This repetitive operation is done through a loop control structure.
A loop is basically the execution of sequence of statements repeatedly until a particular condition is true or false. In 'C' language following loop. statements are used: . mg. while Statements : The while loop repeats a statement or a set of statements until a certain condition is true.
 Syntax:
 while ( condition)
 {
 statements
 }
 Here, the condition may be any expression having non-zero value. The loop continues until the condition is true. When the condition fails, the program body attached with loop (statements), will not be executed.
Example : To print first 20 natural numbers.
 # include < stdio.h >
 #include< conio.h >
 void main ( )
 {
 int a= 1;
 while (a<= 20)
{
printf ("% d", a);
 a++;
}
 getch ();
 }
 • do-while statement:
 Working of this statement is similar to the working of while statement but in this at least one time the attached loop (statements) is executed, ' no matter whether the condition is true or false.
 Syntax⇒
 do
 {
statements
}
while ( condition);

 Example:SYNTAX OF do while To print first 10 odd numbers. 

{
 int a=1;
do
{
 printf (" % d", a);
 a +=2;
 {
 while ( a < = 19);
}

 • for loop statement :  

The for loop is an ideal looping statement when we know how many times the loop will be executed.
Syntax⇒
for (initialization; condition; counter)
 {
statements
}
Here,
 • Initialization is generally an assignment which is used to set the loop control variable, e.g., a= 0.
 • Condition is always tells the limit of the loop or determines when to exit the loop. e.g., a< 10
• Counter defines how the loop control variable will change each time the loop is repeated. This may be incremented or decremented.
 e.g., a++, a--.
Example : To print your name 10 times.
# include < stdio.h >
 #include< conio.h >
void main()
 {
 int i ; char name [20];
 clrscr ( );
 printf ("Enter your name");
 gets (name);
 for(i= l;i<=l0; i++)
 {
 puts (name);
 }
 getch ( );
 }




Sunday, January 13, 2019

variables and data types in C and operators in C

                        variables and data types in C



 variables


 a variable is an entity that has a value and is known to the program by a name. a variable define Associates a memory location with the variable name. a variable can have only one value assigned to eat at any given time during the execution of program . its value may change during the execution of the program.

 example

a=20.5;
b=10;
here, A and B are variables.
  variable  names are identifier used to name variables. they are symbolic names given to memory location. A variable name consists sequence of a  of letters and digits, the first character being a letter. the rules that apply to identify also apply to variable names.

 example of valid variable name are:

a.                    abcl.                     stu-data
class.             employee.             12MAX
 examples of invalid variables  names are:
a's- illegal character(')
Stu data- blank space are not allowed
2MAX- first character should be a letter
Class,mark- comma not allowed

 basic data type :

 the C language support the following basic data types:
char                                         -                                    a single bird that can hold one character
  int                                          -                                   an integer (non-decimal number) (2 bytes space)
float                                         -                                  a number with decimal value ( 4 bytes)
double                                      -                                  number with decimal value (8 bytes)

 qualifiers:

  a qualifiers  alters the characteristics of the data types, such as its size or sign. in c u can apply qualifiers to above data type to get additional data types. the qualifiers that alter the size are 'short' and 'long'.
 short int                           -                           integer represented by a laser number of bits (usually 16)
 long int                            -                       integer represented by a greater number of bits (usually 32)
 long double                      -                          an extended decimal number.
 the expect size of these data types depends on the compiler.

the sign qualifiers are "signed" and "unsigned"

  1. signed int
  2.  signed long int
  3.  unsigned short int
  4. unsigned int
  5. unsigned long int
  6. signed char
  7. unsigned char
normally qualified (short and long) cannot be applied to the data types 4 and plot and sign qualified (signed and unsigned) cannot be applied to float, double and long double.

 operators in C

 operator are symbols that act upon data. they represent a particular operation to do performed on the data. operators can be kal classified  in the following categories:

* arithmetic operators:

The arithmetic operator performs arithmetic operation on any built in data types.
  •  operator.                function
  •  +                            addition
  •  -                              subtraction
  • ×                             multiplication
  • /                              exponentiation
  • %                            modulus (remainder)


* special arithmetic operators


  • ++  increment
  •  - -    decrement

X++ OR ++X is equivalent to X=X+1
 similarly
X-- OR --X is equivalent to X=X-1
 relational operators these operators are used to compare two values on the basis of a certain condition.

*OPERATORS.       FUNCTION


  • <           less than
  • <=         less than equal
  • >            greater than
  • >=          greater than equal
  • !=            not equal to
  • ==            equal to

 logic operators:

 these operators are used to perform logical operations.
 operator      function

  • &&         and
  • ||              OR
  • !              NOT

 assigning operators:

 this operator are used to assign value to variables.
 operator     function

  • =        assign a value
  • +=      add the value and assign it to the left
  • -=       subtract the value and assign it to the left
  • *=       multiply the value and assign it to the left
  • /=        divide the value and assign it to the left
  • %=      find the remainder and assign it to the left


  ternary operators:

 these operators are very powerful operator in C. in some cases it is equivalent to the "if"- else statement.

operation("?") and(":")
 Syntax= expression=exp1?exp2:exp3;
Example:
a=50
b=a>100?25:35 ;
 hear the value of will be 35 because is less than 100 and condition is false.

Saturday, December 29, 2018

STRUCTURE OF C PROGRAM

c programming,jquery,xamarin,selendroid,appium,coded ui,selenium,bangalore,rajajinagar,bootstrap,ios,asp.net mvc,c sharp,c#,ankpro training,ankpro,native language,kid,android,manual testing,tips and tricks,scanf,help,first,computer science (field of study),structured programming (programming language paradigm),comments,clrscr,main,printf,mobile testing,c#6,c#7,azure,knockout,angular,best training,computer training,training,kannada,ankit,maker

                STRUCTURE OF, 'C ' PROGRAM

Before  understanding the structure of  C  program you must know these important points:

* 'C' is a case-sensitive language, it means all the keywords must be written in lower case.
* Keywords can't be used as variable or functions name.
* Every interaction should end with (;)sign:
* Preprocessor main ( ) is must for a program.

NOW TO WRITE A PROGRAM IN  'C' WE NEED TO FELLOW THESES STEPS:

* Define preprocessor directive ( include header files according to prototype Function, standard I/O library function to be used).
* Open function main ( )
* Assign data type and Variables.
* Define the body of the function
* End the function main ( )

EXAMPLE

/* Harsh.c: the first example for students*/

#include<stdio.h>
void main()
{
int a=10, b=15, c;
printf("HELLOW STUDENTS"\n");
c=a+b;
print ("the sum of %d and %d is %d, a,b,c);
}
NOTE: THIS PROGRAM WAS ONLY TOLD TO EXPLAINATION TO YOU.PLEASE DO NOT PAY ATTENTION TO IT'S OUTPUT.

Explanation


First line


IN THE ABOVE EXAMPLE THE FIRST LINE.
/*harsh.c first exmple for students*/
is a comment and non-executable.Comment in 'C' begins with (/*) and ends with(*/).

Second line


#include<stdio.h>
is a preprocessor directive. The preprocessor processes the 'C'  program before the compiler. Here stdio.h is a header file consists of standard I/O Function. A header file related to the function used in the program should be included at the beginning.

THE LINE

void main( )
Indicates "the beginning of the program".The compilation of the program starts from main( ) function.
{, symbol indicates the beginning of main() function.

The line


int a=10,b=15,C;
is for declaration of Variables and data types.
Imp:- int included the only real number.

The Lines


Printf("The sum of %d and %d is %d,a,b,c);
are the body of the program.
and symbol '}' indicates end of main ( ) function.


NOTE: THIS PROGRAM WAS ONLY TOLD TO EXPLAINATION TO YOU.PLEASE DO NOT PAY ATTENTION TO IT'S OUTPUT.


  

Wednesday, December 26, 2018

INTRODUCTION TO ,'C'

INTRODUCTION  TO ,'C'

INTRODUCTION  To 'c'

 Programming Languages is a set of instructions and keywords which helps a user to communicate with the computer. In my blog, you will study programming language 'c'.The 'c' programming language was developed by Dennis Ritchie in bell laboratories, in the early 1970s. Ken Thompson and his team supported him in developing this language. In the last seventies, 'c' began to replace the more familiar languages of that time like PL/I, ALGOL, etc. IN less than a decade of its introduction, 'c' has become a language of choice for software professionals because it is reliable, simple and easy to use. The Unix operating system is written in 'c' language. One of the most interesting about the 'c' language is that its compiler is written in 'c'. 'c' language is considered as a middle-level language since it was designed to have both: a relatively good programming efficiency and a relatively good machine efficiency .it is a bride between low level and high-level language.

* 'c' language possesses features of both low level and high-level languages.
* It provides the facility to do programming with easy approaches.
* It provides the facility to do programming at register level which leads to fast processing.
* It consists of simple English like commands, which are easy to understand.
* The programs are written in 'c' language are 100percent efficient and are also machine independent and portable.
* A 'c' program is easier to write and does not very much from computer to computer.

CHARACTER SET IN 'C'

 The set of characters that may appear in a legal 'c' program is called the character set for 'c'.These include some graphic as well ass non-graphic characters. the 'c' character set consists of an upper case and lower case alphabets, special characters, digits and white spaces. The alphabets and digit together are called the alphanumeric characters.

* ALPHABETS


 A, B, C.......................Y, Z.
 a, b,  c.........................y, z.
'c' is a case-sensitive language, it means lower and upper case are different.

* DIGITS


 0,1,2,3,4,5,6,7,8,9.

* SPECIAL CHARACTERS


 coma  (,)
 Period   (.)
 Semicolon   (;)
 Colon   (:)
 Number sign(Hash)  (#)
 Apostrophe  ( ' )
 Quatation mark  (")
 Exclamation mark  ( !) 
 Vertical bar  ( | )
 Tilde   (~)
 Opening angle bracket  (< )
 Closing angle  bracket  ( >)
 Under source ( _ )
 Dollar sign  ( $ )
 Percent sign  (%)
 Question mark ( ?)
 Ampersand  ( & )
 Caret  ( ^ )
 Asterisk  ( *)
 Minus sign ( - )
 Plus sign  ( + ) 
 slash  ( / )
 Back slash ( \  )
 Left parenthesis   ( 
 Right parenthesis  )
 Left bracket    [
 Right bracker  ]
 Left brace  {
 RIght brace }


BEFORE LEARNING  C PROGRAMMING, WE NEED TO KNOW THIS BASIC INFORMATION.





Tuesday, July 24, 2018

What is Linux commands

What is Linux commands

                      Linux commands

A command is an instruction given to the shell; the kernel will obey that instruction. Linux provides several commands for its users to easily work with it. The important Linux commands are grouped according to their function as a fellow.
Directory Oriented command:

  ls

 this command is used to display the file and sub-directories in the directory.
Syntax is [-options][directory-name]
Example
ls
ls-r
ls*s(it also supports wild character('*' and'?'))
*mkdir: This command is used to make (create) new directories.
Syntax mkdir<directory-name>
Example mkdir harsh

rmdir  

this command is used to remove(delete) the specified directories. A directory should be empty before removing it.
Syntax. rmdir<directory-name>
Example rmdir< TOM>

 cd: 

this command is used to change the current working directory to a specified directory.
Syntax cd< directory-name>
Example cd/home/harsh
cd.

 pwd

 this function (disk usage) command displays the full path names for the current working directory.
Syntax pwd
Example*pwd

du

 this du (disk usage) command report the disk spaces that are consumed by the files in a specified directory, including all its subsidiaries.
Syntax. = du[ -options] [ directory-name] options:
Example du
du-a

df

 this df(disk free) command report the available Free space on the mounted filesystem(disks).
Syntax df[-options]

File Oriented commands

 Cat

 the cat command is used to display the contents of the specified Fi(s).
Syntax= 1cat[file name 1 ]
                2cat>[file name]
Example *cat harsh
                  * cat neeraj

 CP

 this command is used to copy the content of one file to another. If the destination file is an existing directory, the file is copied into that directory.

Syntax= cp [source file][destination file]
Example * cp harsh Pankaj

 rm

 this command is used to remove (delete) a file from the specified directory.to remove a file, you must have written. Permissions for the directory that contains the file, but you need not have permission on the file itself.
Syntax=rm[file name]
Example rm Tom

mv

 this command is used to rename or move a file from one location to another.
Syntax=[source][destination]
Example mv Pankaj Shweta

Wc

 this command is used to count line(l), words(w)and character(c) of information stored on the specified file.
Syntax=wc[-options][file name]
Example wc-1tom

File Access Permissions

 chmod 

 This command is used to change the file permissions for an existing File.
Syntax
1 chmod three-digit-number [file name(s)]
Example chmod u+r,g-x,o+rw[file]

 chown

 this command is used to change the owner of a specified file only the owner of the file and superuser can change the file ownership.
Syntax=chown[new-owner](file name)
Example= chown harsh xyz

chgrp

This command is used to change the group ownership of a specified file.o not the owner of the file and super user can change the file ownership.
Syntax= chgrp[new-group-name](file name)
Example chgrp blic ABC.txt

 Tail

This command displays the end of the specified file. Syntax=tail+n(file name)
number of lines
Example= tail +4abc.txt.

Head

This command displays the top of the specified file.
Syntax=head-n[file-name]
Example=head-3Ajay.dat

General purpose commands


data

This command displays the system's date and time.
Syntax= data+℅D(Data=MM/DD/YY)

who

This command is used to display the user who is you? ( WORKING on current terminals).
Syntax=who
Example who dir name

who am i

This command displays the syntax and details usage of Linux command which is supplied as the argument.
Syntax=man[Linux command]
Example=man data
*

lpr

This command is used to print one more file on the printer.
Syntax= lpr[file name]
Example lpr Tom.txt

File search command

Find 

this command recursively examines directory tree to look for file matching some file attributes and then takes some specified action on those files.

Syntax=find [path -list][selection-criteria][action]
Selection
Example find/home/Tom -m time 5-print

Grep

 the grep(global search for regular expressions( command is used to search for a specified pattern from a specified file and displays those lines containing the pattern.
Syntax=grep[-option] pattern[file name]
Example grep I comp Tom.dat