middle ad

C programs are here.

C PROGRAMS  C (programming language) C programming language is a general-purpose, imperative computer programming language, s...

C PROGRAMS 



C (programming language)

C programming language is a general-purpose, imperative computer programming language, structural support programming, lexical variable scope and recursion, while static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, and therefore has found lasting use in applications that had previously been coded in assembly, including operating systems, as well as various applications for computers ranging from supercomputers to embedded systems .

C was originally developed by Dennis Ritchie between 1969 and 1973 at Bell Labs, and used to re-implement the Unix operating system. It has since become one of the most widely used programming languages ​​of all time, with C compilers from various vendors available for the majority of existing computer architectures and operating systems. C has been standardized by the American National Standards Institute (ANSI) since 1989 (see ANSI C) and subsequently by the International Organization for Standardization (ISO).

C is an imperative procedural language. It was designed to be compiled using a relatively straightforward compiler, to provide a low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require a minimum run-time support. Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standard compliant and portable written C program can be compiled for a wide range of computer platforms and operating systems with few changes to its source code. The language has become available on a wide range of platforms, from embedded microcontrollers to supercomputers.


Syntax


C has a formal grammar specified by the standard C. Line endings are generally not significant in C; However, linear boundaries have significant significance during the preprocessing phase. Comments may appear either between the delimiters / * and * /, or (since C99) following // until the end of the line. Comments delimited by / * and * / do not nest, and these sequences of characters are not interpreted as comment on whether they appear inside string or character literals.



C source files contain declarations and function definitions. Function definitions, in turn, contain declarations and statements. Declarations may define new types using keywords such as struct, union, and enum, or assign types to and possibly reserve storage for new variables, usually by type the type followed by the variable name. Keywords such as char and int specify built-in types. Sections of code are enclosed in braces ({and}, sometimes called "curly brackets") to limit the scope of declarations and to act as a single statement for control structures.

As an imperative language, C uses statements to specify actions. The most common statement is an expression statement, consisting of an expression to be evaluated, followed by a semicolon; have a side effect of the evaluation, functions may be called and variables may be assigned new values. To modify the normal sequential execution of statements, C provides several control-flow statements identified by reserved keywords. Structured programming is supported by if (-else) conditional execution and by do-while, while, and for iterative execution (looping). The for statement has different initialization, testing, and reinitialization expressions, any or all of which can be omitted. break and continue can be used to leave the innermost enclosing loop statement or skip to its reinitialization. There is also a non-structured goto statement which is directly directed to the designated label within the function. select switch to the executed case based on the value of an integer expression.

Expressions can use a variety of built-in operators and may contain function calls. The order in which arguments to operations and operands to most operators are evaluated is unspecified. The evaluations may even be interleaved. However, all side effects (including storage to variables) will occur before the next "sequence point"; The point is included in the end of each statement statement, and the entry to and return from each function call. Sequence points also occur during the evaluation of expressions containing certain operators (&&, ||,?: And the comma operator). This allows a high degree of object code optimization by the compiler, but requires C programmers to take more care to obtain reliable results than is needed for other programming languages.

Kernighan and Ritchie say in the introduction of The C Programming Language: "C, like any other language, has its blemishes. Some of the operators have the wrong precedence; some parts of the syntax could be better." The C standard did not try to correct many of these blemishes, because of the impact of such changes on already existing software.

Character set


The basic C source character set includes the following characters:



Lowercase and uppercase letters of ISO Basic Latin Alphabet: a-z A-Z
Decimal digits: 0-9
Graphic characters:! "#% & '() * +, -. /:; <=>? [\] ^ _ {|} ~
Whitespace characters: space, horizontal tab, vertical tab, form feed, newline
Newline shows the end of a text line; It needs not correspond to a real single character, though for convenience C treats it as one.

Additional multi-byte encoded characters may be used in string literals, but they are not entirely portable. The latest C standard (C11) allows multi-national Unicode characters to be embedded portably within C source text by using \ XXXX or \ XXXXXXXX encoding (although the X is a hexadecimal character), although this feature is not yet widely implemented.

The basic C execution character set contains the same characters, along with representations for alert, backspace, and carriage return. Run-time support for extended character sets has been increased with each revision of the standard C.


Reserved words

C89 has 32 reserved words, also known as keywords, which are the words that can not be used for any purpose other than those for which they are predefined:
C99 reserved five more words:
C11 reserved seven more words:

Most of the recent reserved words begin with a sub-letter followed by a letter, because the identifiers of that form were previously reserved by the C standard for use only by implementations. Since existing program source code should not have been used for these identifiers, it would not be affected when C implementations started to support these extensions to the programming language. Some standard headers do define more convenient synonyms for underscored identifiers. The language previously included a word name  entry, but this was seldom implemented, and has now been removed as a reserve word.


List of C programs



C "Hello, World!" Program





A simple C program to display "Hello, World!" on the screen. Since, it's a very simple program, it is often used to illustrate the syntax of a programming language.


Input
#include <stdio.h>
int main()
{
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}


Output
Hello, World!
How "Hello, World!" program works?
  • The  #include <stdio.h> is a preprocessor command. This command is compiled to include the contents of  stdio.h (standard input and output) file in the program.
    The  stdio.h file contains functions such as  scanf() and  print() to take input and display output respectively.
    If you use  printf() function without writing  #include <stdio.h>, the program will not be compiled.
  • The execution of a C program starts from the  main() function.
  • The  printf() is a library function to send formatted output to the screen. In this program, the  printf() displays Hello, World! text on the screen.
  • The  return 0; statement is the "Exit status" of the program. In simple terms, program ends with this statement.

C Program to Add Two Integers


In this program, user is asked to enter two integers. Then, the sum of those two integers is stored in a variable and displayed on the screen.

Input
#include <stdio.h>
int main()
{
    int firstNumber, secondNumber, sumOfTwoNumbers;
    
    printf("Enter two integers: ");

    // Two integers entered by user is stored using scanf() function
    scanf("%d %d", &firstNumber, &secondNumber);

    // sum of two numbers in stored in variable sumOfTwoNumbers
    sumOfTwoNumbers = firstNumber + secondNumber;

    // Displays sum      
    printf("%d + %d = %d", firstNumber, secondNumber, sumOfTwoNumbers);

    return 0;
}


Output
Enter two integers: 12
11
12 + 11 = 23

In this program, user is asked to enter two integers. Two integers entered by the user are stored in firstNumber  and  secondNumber variables   respectively. This is done using  scanf()function.
Then, firstNumber  and  secondNumber variables   are added using + operator and the result is stored in  sumOfTwoNumbers .

C Program to Find ASCII Value of a Character

In C programming, variable variable holds ASCII value (an integer number between 0 an 127) rather than character itself. You will learn how to find the ASCII value of a character in this program.
For example , ASCII value of 'A' is 65.
This means that, if you assign 'A' to a variable character, 65 is stored in that variable rather than 'A' itself.


Program to Print ASCII Value


Input
#include <stdio.h>
int main()
{
    char c;
    printf("Enter a character: ");

    // Reads character input from the user
    scanf("%c", &c);  
    
    // %d displays the integer value of a character
    // %c displays the actual character
    printf("ASCII value of %c = %d", c, c);
    return 0;
}
Output
Enter a character: G
ASCII value of G = 71

In this program, user is asked to enter a character that is stored in variable  c.  The ASCII value of that character is stored in variable  c  instead of that variable itself.
When% d string format is used, 71 (ASCII value of 'G') is displayed.
When% c string format is used, 'G' itself is displayed.

C Program to Find the Size of int, float, double and char

This program describes 4 variables of type int, float, double and char. Then, the size of each variable is evaluated using sizeof operator.


Example: Program to Find the Size of a variable


Input
#include <stdio.h>
int main()
{
    int integerType;
    float floatType;
    double doubleType;
    char charType;

    // Sizeof operator is used to evaluate the size of a variable
    printf("Size of int: %ld bytes\n",sizeof(integerType));
    printf("Size of float: %ld bytes\n",sizeof(floatType));
    printf("Size of double: %ld bytes\n",sizeof(doubleType));
    printf("Size of char: %ld byte\n",sizeof(charType));

    return 0;
}
Output
Size of int: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
Size of char: 1 byte

In this program, 4 integerType variables  floatTypedoubleType  and  charType  are reported with int, float, double and char type respectively.

Then, the size of each variable is ascertained using sizeof operator. 

C Program to Demonstrate the Working of Keyword Long

The long is a size modifier, indicated by keyword long, that can increase the size of a variable during declaration. This program will show the work of long keyword.


Example: Program to Demonstrate the Working of Long

Input
#include <stdio.h>
int main()
{
    int a;
    long b;
    long long c;

    double e;
    long double f;


    printf("Size of int = %ld bytes \n", sizeof(a));
    printf("Size of long = %ld bytes\n", sizeof(b));
    printf("Size of long long = %ld bytes\n", sizeof(c));

    printf("Size of double = %ld bytes\n", sizeof(e));
    printf("Size of long double = %ld bytes\n", sizeof(f));

    return 0;
}
Output
Size of int = 4 bytes 
Size of long = 8 bytes
Size of long long = 8 bytes
Size of double = 8 bytes
Size of long double = 16 bytes
In this program, the  sizeof operator is used to find the size of  intlonglong longdouble and  long doubleThe long keyword can not be used with  float and  char type variables.


C Program to Check Leap Year

This program checks whether an year (integer) entered by the user is a leap year or not.    A leap year is exactly divisible by 4 except for the century years (years ending with 00). The century year is a leap year only if it is perfectly divisible by 400.


Example: Program to Check Leap Year
Input
#include <stdio.h>

int main()
{
    int year;

    printf("Enter a year: ");
    scanf("%d",&year);

    if(year%4 == 0)
    {
        if( year%100 == 0)
        {
            // year is divisible by 400, hence the year is a leap year
            if ( year%400 == 0)
                printf("%d is a leap year.", year);
            else
                printf("%d is not a leap year.", year);
        }
        else
            printf("%d is a leap year.", year );
    }
    else
        printf("%d is not a leap year.", year);
    
    return 0;
}
Output 1
Enter a year: 1900
1900 is not a leap year.

Enter a year: 2012
2012 is a leap year.










COMMENTS

BLOGGER
Responsive Advertisement
Name

2d,2,A-Level,1,accounting,1,adobe,1,Advance,1,Airtel free internet,1,Album,11,album mpya ya alikiba,1,alikiba new song,2,android,9,Animation,9,application,3,arduino,3,Asphalt 9 legend,1,Avatar,2,Avengers,3,avengers 4,1,Avengers 4 end game,1,avengers 4 endgame,1,bboy,4,beats,1,best,1,Black Adam,1,bongo flavour,1,bravo z11,1,c language,1,captain marvel,1,carter v,1,celebration,1,chainsmoker,1,charismas Songs,1,Charlie Puth,1,Chef,1,Christ mass,2,clouds fm,1,Coding,2,comics,2,Commands,1,computer,1,cooking,1,corona wamefika wangapi tanzania,1,Cracker,1,custom roms,1,dancing,2,Darasa na mario chanda chema,1,dawa ya corona madagascar,1,dawa ya corona yaletwa tanzania,1,dawa ya corona yapatikana,1,DC,1,Disney,2,Dj Khalid,1,Doctor,2,download,15,download captain marvel movie full HD,1,download game,2,electric,1,end game,1,English,1,entrepreneur,4,Excel,1,family,3,fighting game,1,file,1,firm ware,3,firmwares,2,form 5 first selection,1,form five,1,form five second selection,1,Form Four Past Papers,1,form six,1,Form Two Past Papers,1,Form Two Past Papers Questions and Answers,1,friends,1,gamers,4,games,10,God Did,1,gospel,2,gta 5,1,habari mpya leo,1,habari mpya tanzania,1,hackers,2,hackers wallpaper,1,Hacking,7,hakeem bamuyu,1,Hakeem Bamuyu - Jela | Video& Audio,1,hakimu bamuyu,1,harmonize ft angela all nignt,1,harmonize ft angella audio,1,harmonize ft angella official video,1,Harmonize Ft Anjella - All Night (download pm3),1,hesabu,1,Hip Hop,1,hisabati,1,history,3,Home alone,2,how to be attractive,1,inventor,1,ios,4,iron man,1,jconnectiontz,1,jela,1,jipatie pesa mtandaoni kwa ku search tu kwenye google,1,jobs,1,kadogo,1,kali Linux,2,kali Linux 2019.1,1,kids,3,know things about hackers,2,Life hack,7,lil wayne,1,linux,1,love,1,lovers,1,Maisha,1,majibu ya mitihani,1,majina ya walio chaguliwa kujiunga na kidato cha nne mwaka 2018,2,mama,2,Marry X-mass Songs,1,marvel,5,mason.,1,mathematic,1,Matokeo Darasa la Nne,1,Matokeo darasa la Saba,1,Matokeo Kidato cha Nne,1,Matokeo Kidato cha Pili,1,matokeo NECTA,1,matokeo ya darasa la saba 2020,2,matokeo ya darasa la saba 2021 necta,2,matokeo ya darasa la saba 2022,2,matokeo ya motihani,5,Matokeo ya QT,1,Microsoft,2,mitihani,1,mitihani darasa la saba,1,mitihani na majibu,1,Mitihani ya kujipima,1,Mobisol,1,Money,1,mother,1,motivation,1,movie,18,movie kali zote,1,movies,2,Music,1,musician,4,Muvi kali 2019,1,Namna ya kumvutia kila mtu,1,nani ni hacker,2,naruto wallpapers hd,2,NECTA,4,new mods,1,Nfs most wanted,1,nice games. 2019 games,1,notes,9,nyimbo kali,1,online radio,3,panther,1,Past Papers,2,past papers 2022,1,patapesa,1,PDF,11,Pes,1,Picha,4,pictures,1,PlayStation,1,png naruto pics,1,private school past papers,1,pro evolution Soccer,1,programming,2,ps3,2,Psn,2,Qriket app download,1,Questions and Answers Free Download,1,quotes,3,radio one,1,radio ya taifa,1,Ragnarock,2,reason,1,search na google,1,shadow fight highly compressed,1,shule walizopangiwa,2,Sick Boy Save Yourself,1,Simulizi,1,singer,1,software,1,Songs,9,Spider man,2,Standard Four mpangilio wa ufaulu-Kitaifa & Mikoa pdf file,1,Steve jobs,2,stockroms,1,Story,3,Story za Maisha,1,style,1,Sun King,1,Tanzania,3,tbc fm,2,Technical drawing,1,Technology,2,tecno firmwares,1,Templates,1,tengeneza pesa na google,1,there you have it,1,thor,1,tigo fiesta,1,Token taker,1,tricks,7,triple threat,1,ummy mwalimu,1,valentine day,1,vichekesho,2,video,1,vitabu vya darasa la saba,1,Voice Notes,1,wakanda,1,war,1,welcome,4,West life,1,who is whackers,1,windows 10 on android,1,Word,2,x-men,2,Zip,1,Zola,1,
ltr
item
J CONNECTION TZ: C programs are here.
C programs are here.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXfc_cvfVUk6UTg85sgMiVl-XUFO4sUXyE3BnetR9C08_8P6qo0qwJ8A2PaFA8mwYkKreMy8Pz74PL4EuSkCWTbuJ_hfLfA4eCi6k39SP2ryBe9PLTTp_S2CF0bZ23QYf51JM0fv6hwN8/s320/c-programming-language.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXfc_cvfVUk6UTg85sgMiVl-XUFO4sUXyE3BnetR9C08_8P6qo0qwJ8A2PaFA8mwYkKreMy8Pz74PL4EuSkCWTbuJ_hfLfA4eCi6k39SP2ryBe9PLTTp_S2CF0bZ23QYf51JM0fv6hwN8/s72-c/c-programming-language.jpg
J CONNECTION TZ
https://jconnectiontz.blogspot.com/2018/07/c-programs-are-here-jconnectiontz.html
https://jconnectiontz.blogspot.com/
https://jconnectiontz.blogspot.com/
https://jconnectiontz.blogspot.com/2018/07/c-programs-are-here-jconnectiontz.html
true
3165921205566839516
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content